You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@manifoldcf.apache.org by SAUNIER Maxence <MS...@q1c1.fr> on 2018/11/30 13:19:24 UTC
TR: ManifoldCF 2.11, DatTime format in Status and Job Management
Hello Karl,
Can I change the datetime format < MM-dd-yyyy hh:mm:sss > to have < yyyy-MM-dd hh:mm:ss > or < dd-MM-yyyy hh:mm:ss > ?
Thanks,
Re: ManifoldCF 2.11, DatTime format in Status and Job Management
Posted by Karl Wright <da...@gmail.com>.
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 <da...@gmail.com> 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-yyyy 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 <MS...@q1c1.fr> wrote:
>
>> Hello Karl,
>>
>>
>>
>> Can I change the datetime format « MM-dd-yyyy hh:mm:sss » to have
>> « yyyy-MM-dd hh:mm:ss » or « dd-MM-yyyy hh:mm:ss » ?
>>
>>
>>
>> Thanks,
>>
>
Re: ManifoldCF 2.11, DatTime format in Status and Job Management
Posted by Karl Wright <da...@gmail.com>.
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-yyyy 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 <MS...@q1c1.fr> wrote:
> Hello Karl,
>
>
>
> Can I change the datetime format « MM-dd-yyyy hh:mm:sss » to have
> « yyyy-MM-dd hh:mm:ss » or « dd-MM-yyyy hh:mm:ss » ?
>
>
>
> Thanks,
>