Changeset 9739 in josm for trunk/test/unit/org/openstreetmap


Ignore:
Timestamp:
2016-02-04T22:14:23+01:00 (8 years ago)
Author:
simon04
Message:

see #12485 - Fix parsing of sub-seconds

Sometimes there are really strange bugs …

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r9401 r9739  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.util.Date;
    67import java.util.TimeZone;
    78
     
    7475        DateUtils.fromString("2014-");
    7576    }
     77
     78    /**
     79     * Tests that formatting a date w/ milliseconds does not cause incorrect parsing afterwards
     80     */
     81    @Test
     82    public void testFormattingMillisecondsDoesNotCauseIncorrectParsing() {
     83        DateUtils.fromDate(new Date(123));
     84        assertEquals(1453694709000L, DateUtils.fromString("2016-01-25T04:05:09.000Z").getTime());
     85        assertEquals(1453694709200L, DateUtils.fromString("2016-01-25T04:05:09.200Z").getTime());
     86        assertEquals(1453694709400L, DateUtils.fromString("2016-01-25T04:05:09.400Z").getTime());
     87    }
    7688}
Note: See TracChangeset for help on using the changeset viewer.