Hi I noticed that Joda DateTime created using Zone is returning toDate as per Current System Date. I was expecting toDate to return as per Created DateTime. As per Joda API, it says toDate should return Date initialised with this datetime. I am using Joda 2.9.4 in my Maven. Any thoughts from Gurus out in SO
public class TestJodaError {
public static void main(String[] args) {
DateTime ldt = new DateTime();
System.out.println("Local dt: " + ldt + " toDate: " + ldt.toDate());
String tzId = "Asia/Singapore";
ZoneId zoneId = ZoneId.of(tzId);
ZonedDateTime zdt = ZonedDateTime.now(zoneId);
DateTimeZone dtZone = DateTimeZone.forID(zdt.getZone().getId());
DateTime rdt = new DateTime(dtZone);
System.out.println("Remote dt: " + rdt + " toDate: " + rdt.toDate());
}}
Results are
Local dt: 2019-05-17T11:33:30.333+05:30 toDate: Fri May 17 11:33:30 IST 2019
Remot dt: 2019-05-17T14:03:30.738+08:00 toDate: Fri May 17 11:33:30 IST 2019
Expected Results
Remot dt: 2019-05-17T14:03:30.738+08:00 toDate: Fri May 17 14:03:30 SGT 2019