I need to build a date format like dd/MM/yyyy
. It\'s almost like DateFormat.SHORT
, but contains 4 year digits.
I try to implement it with
I have similar way to do this, but I need to get the locale pattern for the ui controller.
So here's the code
// date format, always using yyyy as year display
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
SimpleDateFormat simple = (SimpleDateFormat) dateFormat;
String pattern = simple.toPattern().replaceAll("\\byy\\b", "yyyy");
System.out.println(pattern);