If I run the following code in Java 8:-
package au.com.tt.agora.debug.web;
import java.util.TimeZone;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
public class Test
{
public static void main(String[] args)
{
String newDate = new LocalDate().toString("ddMMMyy");
System.out.println(newDate);
System.out.println(TimeZone.getDefault());
System.out.println(DateTimeZone.getDefault());
}
}
I get this result:-
14Apr20
sun.util.calendar.ZoneInfo[id="Australia/Sydney",offset=36000000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=Australia/Sydney,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=3,endMonth=3,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]]
Australia/Sydney
I run the same code in Java 11 I get the following result:-
14Apr.20
sun.util.calendar.ZoneInfo[id="Australia/Sydney",offset=36000000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=Australia/Sydney,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=3,endMonth=3,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]]
Australia/Sydney
Note the . between Apr and 20. Is this a bug or a new feature of Joda date time in Java 11?
UPDATE I am using Joda v2.10.5. Also, this code:-
package au.com.tt.agora.debug.web;
import java.time.format.DateTimeFormatter; import java.util.TimeZone;
import org.joda.time.DateTimeZone; import org.joda.time.LocalDate;
public class Test
{
public static void main(String[] args)
{
LocalDate joda = new LocalDate();
java.time.LocalDate date = java.time.LocalDate.of(joda.getYear(), joda.getMonthOfYear(), joda.getDayOfMonth());
System.out.println(date.format(DateTimeFormatter.ofPattern("ddMMMyy")));
System.out.println(TimeZone.getDefault());
System.out.println(DateTimeZone.getDefault());
}
}
produces the same result for the date. I am using Java 11.0.6 on Windows.
UPDATE 2 Turns out it is a locale problem. Between Java 8 and Java 11 there was a change in the way certain locales (en_AU and en_CA specifically) deal with dates. See here for more details:-
https://bugs.openjdk.java.net/browse/JDK-8211750
Have to work out what I have to do in this case, but at least I understand the problem.