RFR: 8135108: java/util/zip/TestLocalTime.java fails intermittently with Invalid value for NanoOfSecond
Joseph D. Darcy
joe.darcy at oracle.com
Tue Feb 16 01:25:47 UTC 2016
Looks fine Sherman; thanks,
-Joe
On 2/15/2016 2:45 PM, Xueming Shen wrote:
> Hi,
>
> Please help review the changes for JDK-8135108
>
> issue: https://bugs.openjdk.java.net/browse/JDK-8135108
> webrev: http://cr.openjdk.java.net/~sherman/8135108
>
> It's a overflow of the low 32-bit of xdostime when the year is > 0x70
> (which will be shifting << 25). We have a similar patch at
> ZipUtils.javaToDosTime(). Obviously ZipEntry.setTimeLocale() needs
> one as well.
>
> /**
> * Converts Java time to DOS time.
> */
> private static long javaToDosTime(long time) {
> Instant instant = Instant.ofEpochMilli(time);
> LocalDateTime ldt = LocalDateTime.ofInstant(
> instant, ZoneId.systemDefault());
> int year = ldt.getYear() - 1980;
> if (year < 0) {
> return (1 << 21) | (1 << 16);
> }
> return (year << 25 |
> ldt.getMonthValue() << 21 |
> ldt.getDayOfMonth() << 16 |
> ldt.getHour() << 11 |
> ldt.getMinute() << 5 |
> ldt.getSecond() >> 1) & 0xffffffffL;
> }
>
> Thanks!
> Sherman
More information about the core-libs-dev
mailing list