When UTC date is formatted by DateFormat#format()
, I expect to get a String
of UTC date formatted, but not.
Please look at the code below. These tests are passed.
My question is why does DateFormat#format()
return a time of 12:00 past UTC date? What am I missing here?
Date date(int millisecondsSinceEpoch, bool isUtc) =>
new Date.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, isUtc:isUtc);
DateFormat df = new DateFormat("yyyy-MM-dd hh:mm");
// JST (+9.00)
expect(date(0, false).toString(), equals("1970-01-01 09:00:00.000"));
expect(df.format(date(0, false)), equals("1970-01-01 09:00"));
expect(date(0, true).toString(), equals("1970-01-01 00:00:00.000Z"));
// Why 12 o'clock?
expect(df.format(date(0, true)), equals("1970-01-01 12:00"));