joda time, DateTimeFormatter

I have following code

dateTimeFormat = ISODateTimeFormat.dateTimeNoMillis()

and i use dateTimeFormat below

public static String print(Date value) {
    return dateTimeFormat.print(value.getTime());
}

And now i get problem, in my print method i put many date instances with + 4 hours time, and after dateTimeFormat.print(value.getTime()); i get time with +3 hour, but one of all date instances become with +4 hours, this error for me.

In all date instances has the same time zone Europe/Moscow

What may be wrong in my case?

Jon Skeet
people
quotationmark

In all date instances has the same time zone Europe/Moscow

A Date instance doesn't have a time zone - it's just an instant in time. But you should probably specify the time zone for your formatter, e.g.

dateTimeFormat = ISODateTimeFormat
    .dateTimeNoMillis()
    .withZoneUTC();

If you want a value which does know about a time zone, you should use DateTime instead of Date.

people

See more on this question at Stackoverflow