Serializing Calendar objects with certain timezone offsets renders invalid yaml
Issue #364
resolved
Hi,
Serializing Calendar objects with certain timezone offsets renders invalid YAML. The below unit test showcases the problem:
public void testTimestampNegativeTimezoneOffset() {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-1:15"));
cal.clear();
cal.set(2008, 8, 23, 14, 35, 4);
Map<String, Calendar> map = new HashMap<String, Calendar>();
map.put("canonical", cal);
String output = dump(map);
assertEquals("{canonical: !!timestamp '2008-09-23T14:35:04-01:15'}\n", output);
}
Using SnakeYaml 1.18, the output is:
{canonical: !!timestamp '2008-09-23T14:35:04-1:0-15'}
Which is not valid YAML and thus SnakeYaml cannot read it's own output.
I'll send a pull request with a fix shortly.
Cheers, Oscar
Comments (2)
-
reporter -
- Log in to comment
Several other offsets that are rendered incorrectly are "GMT+00:30" and "GMT+00:00", output is "2008-09-23T14:35:040:30" and "2008-09-23T14:35:040:00" respectively.