1 26 27 29 package de.nava.informa.utils; 30 31 import java.util.Calendar ; 32 import java.util.Date ; 33 import java.util.GregorianCalendar ; 34 import java.util.TimeZone ; 35 36 public class TestParserUtils extends InformaTestCase { 37 38 public TestParserUtils(String name) { 39 super("TestParserUtils", name); 40 } 41 42 public void testParseDateFmt() { 43 String strdate = "Wed, 07 Aug 2002 00:32:05 GMT"; 44 Date resDate = ParserUtils.getDate(strdate); 45 46 47 Calendar expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 48 expDate.set(2002, Calendar.AUGUST, 7, 0, 32, 5); 49 expDate.set(Calendar.MILLISECOND, 0); 50 51 assertEquals(expDate.getTime(), resDate); 52 53 strdate = "2002-08-07T15:32:05-0500 "; 54 resDate = ParserUtils.getDate(strdate); 55 56 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 57 expDate.set(2002, Calendar.AUGUST, 7, 20, 32, 5); 58 expDate.set(Calendar.MILLISECOND, 0); 59 assertEquals(expDate.getTime(), resDate); 60 61 strdate = "2002-08-07T15:32:05-05:00 "; 62 resDate = ParserUtils.getDate(strdate); 63 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 64 expDate.set(2002, Calendar.AUGUST, 7, 20, 32, 5); 65 expDate.set(Calendar.MILLISECOND, 0); 66 assertEquals(expDate.getTime(), resDate); 67 68 strdate = "2002-08-07T12:32:05+03:00 "; 69 resDate = ParserUtils.getDate(strdate); 70 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 71 expDate.set(2002, Calendar.AUGUST, 7, 9, 32, 5); 72 expDate.set(Calendar.MILLISECOND, 0); 73 assertEquals(expDate.getTime(), resDate); 74 75 strdate = "2002-08-07T12:32:05 GMT"; 76 resDate = ParserUtils.getDate(strdate); 77 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 78 expDate.set(2002, Calendar.AUGUST, 7, 12, 32, 5); 79 expDate.set(Calendar.MILLISECOND, 0); 80 assertEquals(expDate.getTime(), resDate); 81 82 strdate = "2002-08-07T12:32:05 RET"; 83 resDate = ParserUtils.getDate(strdate); 84 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 85 expDate.set(2002, Calendar.AUGUST, 7, 8, 32, 5); expDate.set(Calendar.MILLISECOND, 0); 87 assertEquals(expDate.getTime(), resDate); 88 89 strdate = "2002-08-07T12:32:05Z"; 90 resDate = ParserUtils.getDate(strdate); 91 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 92 expDate.set(2002, Calendar.AUGUST, 7, 12, 32, 5); 93 expDate.set(Calendar.MILLISECOND, 0); 94 assertEquals(expDate.getTime(), resDate); 95 96 strdate = "2002-08-07T12:32:05+3:00 "; 97 resDate = ParserUtils.getDate(strdate); 98 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 99 expDate.set(2002, Calendar.AUGUST, 7, 9, 32, 5); 100 expDate.set(Calendar.MILLISECOND, 0); 101 assertEquals(expDate.getTime(), resDate); 102 103 strdate = "2002-08-07T06:32:05-3:00 "; 104 resDate = ParserUtils.getDate(strdate); 105 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 106 expDate.set(2002, Calendar.AUGUST, 7, 9, 32, 5); 107 expDate.set(Calendar.MILLISECOND, 0); 108 assertEquals(expDate.getTime(), resDate); 109 110 strdate = "2002-08-07T12:32:05GMT-02:00"; 111 resDate = ParserUtils.getDate(strdate); 112 expDate = new GregorianCalendar (TimeZone.getTimeZone("GMT")); 113 expDate.set(2002, Calendar.AUGUST, 7, 14, 32, 5); 114 expDate.set(Calendar.MILLISECOND, 0); 115 assertEquals(expDate.getTime(), resDate); 116 } 117 118 public void testUnescape() { 119 String testString = "&gt; > " < '"; 120 assertEquals("> > \" < '", ParserUtils.unEscape(testString) ); 122 } 123 } 124 | Popular Tags |