Locale dependency of JMH, div by 0 in ListStatistics
Erich Schubert
erich at debian.org
Mon Dec 22 16:03:50 UTC 2014
Hello Aleksey,
I get the error message
# Can not figure out JMH version, unable to parse the build time: Fri
Dec 19 08:54:04 UTC 2014
And I guess it expects this to be "Fre Dez ..." because I'm in German locale.
If I use this pattern to format, I get
Mo Dez 22 16:57:48 MEZ 2014
It should be enough to use this:
new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ROOT);
(Note the added Locale.ROOT!)
As long as the maven build process also ensures root locale - e.g. by
setting timestamp.locale.
But IMHO the cleaner approach is to avoid any locale dependant field
such as EEE MMM and zzz (!) in the timestamp, if you plan on parsing
it later again.
If parsing fails, it should still report the version number, even when
the age is not available.
Regards,
Erich
On Mon, Dec 22, 2014 at 4:09 PM, Aleksey Shipilev
<aleksey.shipilev at oracle.com> wrote:
> On 12/22/2014 05:20 PM, Aleksey Shipilev wrote:
>>>> 1. Running JMH in a different locale prevents it from reporting its
>>>> version number.
>>>> I'm using the maven version (1.4) which apparently was built with C
>>>> locale. But SimpleDateFormat defaults to using the system locale, and
>>>> thus fails to parse the locale-depedant timestamp format that was
>>>> used.
>>>>
>>>> IMHO the cleanest way is to use a non-locale timestamp, such as RFC 3339.
>>>
>>> https://bugs.openjdk.java.net/browse/CODETOOLS-7901226
>
> Um. I am trying to understand this bug. Our build emits the timestamp in
> a preset format:
>
> <timestamp>${maven.build.timestamp}</timestamp>
> <maven.build.timestamp.format>EEE MMM dd HH:mm:ss zzz
> yyyy</maven.build.timestamp.format>
>
> ...and Java code picks up the timestamp in the same format:
>
> Date parse = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz
> yyyy").parse(time);
>
> Does this mean Erich's Maven ignores maven.build.timestamp.format?
> Erich, can you show the run log?
>
> Thanks,
> -Aleksey.
>
More information about the jmh-dev
mailing list