Может кто-нибудь, пожалуйста, объясните мне, как работает часовой пояс joda DateTime? У меня есть:joda DateTime часовой пояс
public static void main(String[] args) {
DateTime utc = new DateTime(new Date()).withZone(DateTimeZone.UTC);
DateTime nonUtc = new DateTime(new Date());
long l = DateTimeZone.UTC.convertLocalToUTC(new Date().getTime(), false);
DateTime converted = new DateTime(l);
System.out.println("UTC :"+utc.toDate() + " , time zone :"+utc.getZone().getID());
System.out.println("Non UTC :"+nonUtc.toDate()+ " , time zone :"+nonUtc.getZone().getID());
System.out.println("Converted :"+converted.toDate()+ " , time zone :"+converted.getZone().getID());
}
Результат этого ниже. Местный часовой пояс по умолчанию Europe/Athens
UTC :Thu Sep 03 10:40:30 EEST 2015 , time zone :UTC
Non UTC :Thu Sep 03 10:40:30 EEST 2015 , time zone :Europe/Athens
Converted :Thu Sep 03 10:40:30 EEST 2015 , time zone :Europe/Athens
Я понимаю, что первый один создает new Date()
в UTC со временем от моего по умолчанию TZ, второй создает new Date()
с т.з. по умолчанию, но почему же не последний строка преобразует местное время в UTC?