source: josm/test/org/openstreetmap/josm/testframework/DateParserTest.java@ 135

Last change on this file since 135 was 135, checked in by imi, 18 years ago
  • fixed test directory structure
  • shortkeys do not cycle through modes anymore
  • Ctrl+, and Ctrl+. to zoom in/out. Should work on Mac now.
File size: 1.0 KB
Line 
1package org.openstreetmap.josm.testframework;
2
3import java.text.ParseException;
4import java.text.SimpleDateFormat;
5import java.util.Date;
6
7import junit.framework.TestCase;
8
9import org.openstreetmap.josm.tools.DateParser;
10
11public class DateParserTest extends TestCase {
12
13 public void testWrong() throws Exception {
14 try {
15 DateParser.parse("imi");
16 assertTrue(false);
17 } catch (ParseException pe) {
18 }
19 }
20
21 public void testRight() throws Exception {
22 Date d = new SimpleDateFormat("dd MM yyyy HH mm ss SSS Z").parse("23 11 2001 23 05 42 123 +0100");
23 Date d2 = new Date(d.getTime()-123);
24 assertEquals(d2, DateParser.parse("11/23/2001 23:05:42"));
25 assertEquals(d2, DateParser.parse("11/23/2001T23:05:42"));
26 assertEquals(d2, DateParser.parse("11/23/2001T23:05:42+001"));
27 assertEquals(d2, DateParser.parse("2001-11-23T23:05:42+01:00"));
28 assertEquals(d, DateParser.parse("11/23/2001T23:05:42.123"));
29 assertEquals(d, DateParser.parse("11/23/2001T23:05:42.123+001"));
30 }
31}
Note: See TracBrowser for help on using the repository browser.