I am producing a file that needs English/ASCII/C Locale. One part calls
public static String yearday(Date d) {
return String.format(null, "%te.%tb.%tY", d, d, d);
}
String.format documentation says the Local can be null:
l - The locale to apply during formatting. If l is null then no localization
is applied. This does not change this object's locale that was set during
construction.
However, attempting to pass the null Locale yields:
Exception in thread "main" java.lang.NullPointerException
at java.util.Calendar.createCalendar(Calendar.java:962)
at java.util.Calendar.getInstance(Calendar.java:937)
at java.util.Formatter$FormatSpecifier.printDateTime(Formatter.java:2738)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2651)
at java.util.Formatter.format(Formatter.java:2430)
at java.util.Formatter.format(Formatter.java:2364)
at java.lang.String.format(String.java:2564)
at com.sun.WHATEVER.yearday(MYFILE.java:191)
###@###.### 2005-06-08 01:18:51 GMT
public static String yearday(Date d) {
return String.format(null, "%te.%tb.%tY", d, d, d);
}
String.format documentation says the Local can be null:
l - The locale to apply during formatting. If l is null then no localization
is applied. This does not change this object's locale that was set during
construction.
However, attempting to pass the null Locale yields:
Exception in thread "main" java.lang.NullPointerException
at java.util.Calendar.createCalendar(Calendar.java:962)
at java.util.Calendar.getInstance(Calendar.java:937)
at java.util.Formatter$FormatSpecifier.printDateTime(Formatter.java:2738)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2651)
at java.util.Formatter.format(Formatter.java:2430)
at java.util.Formatter.format(Formatter.java:2364)
at java.lang.String.format(String.java:2564)
at com.sun.WHATEVER.yearday(MYFILE.java:191)
###@###.### 2005-06-08 01:18:51 GMT