Changeset 9383 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2016-01-10T13:04:06+01:00 (9 years ago)
Author:
simon04
Message:

Deprecate PrimaryDateParser in favour of DateUtils

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
1 added
1 edited

Legend:

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

    r8876 r9383  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.util.TimeZone;
     7
     8import org.junit.BeforeClass;
    69import org.junit.Test;
    710
     
    1013 */
    1114public class DateUtilsTest {
     15
     16    /**
     17     * Setup test.
     18     */
     19    @BeforeClass
     20    public static void setUp() {
     21        TimeZone.setDefault(TimeZone.getTimeZone("GMT+8:00"));
     22    }
    1223
    1324    /**
     
    2637        assertEquals(1417298930000L, DateUtils.fromString("2014-11-29 22:08:50 UTC").getTime());
    2738    }
     39
     40    /**
     41     * Test to parse date as used in EXIF structures.
     42     */
     43    @Test
     44    public void testExifDate() {
     45        assertEquals(1443038712000L - 8 * 3600 * 1000, DateUtils.fromString("2015:09:23 20:05:12").getTime());
     46        assertEquals(1443038712888L - 8 * 3600 * 1000, DateUtils.fromString("2015:09:23 20:05:12.888").getTime());
     47    }
     48
     49    /**
     50     * Test to parse date as used in GPX files
     51     */
     52    @Test
     53    public void testGPXDate() {
     54        assertEquals(1277465405000L, DateUtils.fromString("2010-06-25T11:30:05.000Z").getTime());
     55    }
     56
     57    /**
     58     * Test to parse date as defined in <a href="https://tools.ietf.org/html/rfc3339">RFC 3339</a>
     59     */
     60    @Test
     61    public void testRfc3339() {
     62        // examples taken from RFC
     63        assertEquals(482196050520L, DateUtils.fromString("1985-04-12T23:20:50.52Z").getTime());
     64        assertEquals(851042397000L, DateUtils.fromString("1996-12-19T16:39:57-08:00").getTime());
     65        assertEquals(-1041337172130L, DateUtils.fromString("1937-01-01T12:00:27.87+00:20").getTime());
     66    }
    2867}
Note: See TracChangeset for help on using the changeset viewer.