I looked again at what is available natively under Java for locale-specific
date formatting. The only game in town seems to be DateFormat, which has
only 9 canned configurations for date/time formatting. The one that most
closely matches what we do now comes out like this for US:
' 11/30/18 10:14:53 AM'
This is not quite what you want since you don't get milliseconds and you
don't get a 4-character year either. But it's the best I can do with
off-the-shelf stuff, other than to make the format be configurable in
properties.xml, which I'm not thrilled with.
Karl
On Fri, Nov 30, 2018 at 9:14 AM Karl Wright wrote:
> The dates/times for this page are formatted as follows:
>
> org.apache.manifoldcf.ui.util.Formatter.formatTime(clientTimezone,
> pageContext.getRequest().getLocale(), js.getStartTime());
>
> But the code for formatTime pays no attention to the preferred format for
> the locale:
>
> public static String formatTime(TimeZone tz, Locale locale, long time)
> {
> Calendar c = new GregorianCalendar(tz, locale);
> c.setTimeInMillis(time);
> // We want to format this string in a compact way:
> // mm-dd- hh:mm:ss.mmm
> StringBuilder returnString = new StringBuilder();
> writechars(returnString,c.get(Calendar.MONTH)+1,2);
> returnString.append("-");
> writechars(returnString,c.get(Calendar.DAY_OF_MONTH),2);
> returnString.append("-");
> writechars(returnString,c.get(Calendar.YEAR),4);
> returnString.append(" ");
> writechars(returnString,c.get(Calendar.HOUR_OF_DAY),2);
> returnString.append(":");
> writechars(returnString,c.get(Calendar.MINUTE),2);
> returnString.append(":");
> writechars(returnString,c.get(Calendar.SECOND),2);
> returnString.append(".");
> writechars(returnString,c.get(Calendar.MILLISECOND),3);
> return returnString.toString();
> }
>
>
> So if you would like this to be changed you might want to create an
> enhancement request.
>
> Thanks,
> Karl
>
>
>
>
> On Fri, Nov 30, 2018 at 8:43 AM SAUNIER Maxence wrote:
>
>> Hello Karl,
>>
>>
>>
>> Can I change the datetime format « MM-dd- hh:mm:sss » to have
>> « -MM-dd hh:mm:ss » or « dd-MM- hh:mm:ss » ?
>>
>>
>>
>> Thanks,
>>
>