You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/09/26 22:44:17 UTC
svn commit: r1390722 - in /commons/proper/lang/trunk/src:
main/java/org/apache/commons/lang3/time/FastDateParser.java
test/java/org/apache/commons/lang3/time/FastDateParserTest.java
Author: sebb
Date: Wed Sep 26 20:44:16 2012
New Revision: 1390722
URL: http://svn.apache.org/viewvc?rev=1390722&view=rev
Log:
Trailing spaces
Modified:
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java?rev=1390722&r1=1390721&r2=1390722&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java Wed Sep 26 20:44:16 2012
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,18 +41,18 @@ import java.util.regex.Pattern;
/**
* <p>FastDateParser is a fast and thread-safe version of
* {@link java.text.SimpleDateFormat}.</p>
- *
+ *
* <p>This class can be used as a direct replacement for
* <code>SimpleDateFormat</code> in most parsing situations.
* This class is especially useful in multi-threaded server environments.
* <code>SimpleDateFormat</code> is not thread-safe in any JDK version,
- * nor will it be as Sun have closed the
+ * nor will it be as Sun have closed the
* <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4228335">bug</a>/RFE.
* </p>
*
* <p>Only parsing is supported, but all patterns are compatible with
* SimpleDateFormat.</p>
- *
+ *
* <p>Timing tests indicate this class is as about as fast as SimpleDateFormat
* in single thread applications and about 25% faster in multi-thread applications.</p>
*
@@ -68,12 +68,12 @@ import java.util.regex.Pattern;
public class FastDateParser implements DateParser, Serializable {
/**
* Required for serialization support.
- *
+ *
* @see java.io.Serializable
*/
private static final long serialVersionUID = 1L;
-
- private static final ConcurrentMap<Locale,TimeZoneStrategy> tzsCache=
+
+ private static final ConcurrentMap<Locale,TimeZoneStrategy> tzsCache=
new ConcurrentHashMap<Locale,TimeZoneStrategy>(3);
static final Locale JAPANESE_IMPERIAL = new Locale("ja","JP","JP");
@@ -82,7 +82,7 @@ public class FastDateParser implements D
private final String pattern;
private final TimeZone timeZone;
private final Locale locale;
-
+
// derived fields
private transient Pattern parsePattern;
private transient Strategy[] strategies;
@@ -95,7 +95,7 @@ public class FastDateParser implements D
/**
* <p>Constructs a new FastDateParser.</p>
- *
+ *
* @param pattern non-null {@link java.text.SimpleDateFormat} compatible
* pattern
* @param timeZone non-null time zone to use
@@ -104,22 +104,22 @@ public class FastDateParser implements D
protected FastDateParser(String pattern, TimeZone timeZone, Locale locale) {
this.pattern = pattern;
this.timeZone = timeZone;
- this.locale = locale;
+ this.locale = locale;
init();
}
-
+
/**
* Initialize derived fields from defining fields.
- * This is called from constructor and from readObject (de-serialization)
+ * This is called from constructor and from readObject (de-serialization)
*/
private void init() {
thisYear= Calendar.getInstance(timeZone, locale).get(Calendar.YEAR);
-
+
nameValues= new ConcurrentHashMap<Integer, KeyValue[]>();
-
+
StringBuilder regex= new StringBuilder();
List<Strategy> collector = new ArrayList<Strategy>();
-
+
Matcher patternMatcher= formatPattern.matcher(pattern);
if(!patternMatcher.lookingAt()) {
throw new IllegalArgumentException("Invalid pattern");
@@ -136,19 +136,19 @@ public class FastDateParser implements D
String nextFormatField= patternMatcher.group();
nextStrategy = getStrategy(nextFormatField);
if(currentStrategy.addRegex(this, regex)) {
- collector.add(currentStrategy);
+ collector.add(currentStrategy);
}
currentFormatField= nextFormatField;
currentStrategy= nextStrategy;
}
if(currentStrategy.addRegex(this, regex)) {
- collector.add(currentStrategy);
+ collector.add(currentStrategy);
}
currentFormatField= null;
strategies= collector.toArray(new Strategy[collector.size()]);
parsePattern= Pattern.compile(regex.toString());
}
-
+
// Accessors
//-----------------------------------------------------------------------
/* (non-Javadoc)
@@ -179,7 +179,7 @@ public class FastDateParser implements D
//-----------------------------------------------------------------------
/**
* <p>Compare another object for equality with this object.</p>
- *
+ *
* @param obj the object to compare to
* @return <code>true</code>if equal to this instance
*/
@@ -190,13 +190,13 @@ public class FastDateParser implements D
}
FastDateParser other = (FastDateParser) obj;
return pattern.equals(other.pattern)
- && timeZone.equals(other.timeZone)
+ && timeZone.equals(other.timeZone)
&& locale.equals(other.locale);
}
/**
* <p>Return a hashcode compatible with equals.</p>
- *
+ *
* @return a hashcode compatible with equals
*/
@Override
@@ -206,7 +206,7 @@ public class FastDateParser implements D
/**
* <p>Get a string version of this formatter.</p>
- *
+ *
* @return a debugging string
*/
@Override
@@ -217,7 +217,7 @@ public class FastDateParser implements D
// Serializing
//-----------------------------------------------------------------------
/**
- * Create the object after serialization. This implementation reinitializes the
+ * Create the object after serialization. This implementation reinitializes the
* transient properties.
*
* @param in ObjectInputStream from which the object is being deserialized.
@@ -228,7 +228,7 @@ public class FastDateParser implements D
in.defaultReadObject();
init();
}
-
+
/* (non-Javadoc)
* @see org.apache.commons.lang3.time.DateParser#parseObject(java.lang.String)
*/
@@ -284,7 +284,7 @@ public class FastDateParser implements D
pos.setIndex(offset+matcher.end());
return cal.getTime();
}
-
+
// Support for strategies
//-----------------------------------------------------------------------
@@ -336,7 +336,7 @@ public class FastDateParser implements D
}
return regex;
}
-
+
/**
* A class to store Key / Value pairs
*/
@@ -345,7 +345,7 @@ public class FastDateParser implements D
public int value;
/**
- * Construct a Key / Value pair
+ * Construct a Key / Value pair
* @param key The key
* @param value The value
*/
@@ -354,7 +354,7 @@ public class FastDateParser implements D
this.value= value;
}
}
-
+
/**
* ignore case comparison of keys
*/
@@ -362,7 +362,7 @@ public class FastDateParser implements D
@Override
public int compare(KeyValue left, KeyValue right) {
return left.key.compareToIgnoreCase(right.key);
- }
+ }
};
/**
@@ -418,9 +418,9 @@ public class FastDateParser implements D
}
return eras;
}
-
+
/**
- * Create key / value pairs from keys
+ * Create key / value pairs from keys
* @param longValues The allowable long names for a field
* @param shortValues The optional allowable short names for a field
* @return The sorted name / value pairs for the field
@@ -433,7 +433,7 @@ public class FastDateParser implements D
}
/**
- * Get a count of valid values in array. A valid value is of non-zero length.
+ * Get a count of valid values in array. A valid value is of non-zero length.
* @param values The values to check. This parameter may be null
* @return The number of valid values
*/
@@ -450,9 +450,9 @@ public class FastDateParser implements D
}
/**
- * Create key / value pairs from values
+ * Create key / value pairs from values
* @param fieldKeyValues The destination array
- * @param offset The offset into the destination array
+ * @param offset The offset into the destination array
* @param values The values to use to create key / value pairs. This parameter may be null.
* @return The offset into the destination array
*/
@@ -483,12 +483,12 @@ public class FastDateParser implements D
/**
* Is the next field a number?
- * @return true, if next field will be a number
+ * @return true, if next field will be a number
*/
boolean isNextNumber() {
return nextStrategy!=null && nextStrategy.isNumber();
}
-
+
/**
* What is the width of the current field?
* @return The number of characters in the current format field
@@ -496,7 +496,7 @@ public class FastDateParser implements D
int getFieldWidth() {
return currentFormatField.length();
}
-
+
/**
* A strategy to parse a single field from the parsing pattern
*/
@@ -514,22 +514,22 @@ public class FastDateParser implements D
*/
void setCalendar(FastDateParser parser, Calendar cal, String value);
/**
- * Generate a <code>Pattern</code> regular expression to the <code>StringBuilder</code>
+ * Generate a <code>Pattern</code> regular expression to the <code>StringBuilder</code>
* which will accept this field
* @param parser The parser calling this strategy
* @param regex The <code>StringBuilder</code> to append to
- * @return true, if this field will set the calendar;
- * false, if this field is a constant value
+ * @return true, if this field will set the calendar;
+ * false, if this field is a constant value
*/
boolean addRegex(FastDateParser parser, StringBuilder regex);
}
-
+
/**
* A <code>Pattern</code> to parse the user supplied SimpleDateFormat pattern
*/
private static final Pattern formatPattern= Pattern.compile(
"D+|E+|F+|G+|H+|K+|M+|S+|W+|Z+|a+|d+|h+|k+|m+|s+|w+|y+|z+|''|'[^']++(''[^']*+)*+'|[^'A-Za-z]++");
-
+
/**
* Obtain a Strategy given a field from a SimpleDateFormat pattern
* @param formatField A sub-sequence of the SimpleDateFormat pattern
@@ -615,11 +615,11 @@ public class FastDateParser implements D
public boolean isNumber() {
char c= formatField.charAt(0);
if(c=='\'') {
- c= formatField.charAt(1);
+ c= formatField.charAt(1);
}
return Character.isDigit(c);
}
-
+
/**
* {@inheritDoc}
*/
@@ -642,7 +642,7 @@ public class FastDateParser implements D
*/
private static class TextStrategy implements Strategy {
private final int field;
-
+
/**
* Construct a Strategy that parses a Text field
* @param field The Calendar field
@@ -650,7 +650,7 @@ public class FastDateParser implements D
TextStrategy(int field) {
this.field= field;
}
-
+
/**
* {@inheritDoc}
*/
@@ -658,7 +658,7 @@ public class FastDateParser implements D
public boolean isNumber() {
return false;
}
-
+
/**
* {@inheritDoc}
*/
@@ -671,7 +671,7 @@ public class FastDateParser implements D
regex.setCharAt(regex.length()-1, ')');
return true;
}
-
+
/**
* {@inheritDoc}
*/
@@ -697,7 +697,7 @@ public class FastDateParser implements D
*/
private static class NumberStrategy implements Strategy {
protected final int field;
-
+
/**
* Construct a Strategy that parses a Number field
* @param field The Calendar field
@@ -705,7 +705,7 @@ public class FastDateParser implements D
NumberStrategy(int field) {
this.field= field;
}
-
+
/**
* {@inheritDoc}
*/
@@ -713,7 +713,7 @@ public class FastDateParser implements D
public boolean isNumber() {
return true;
}
-
+
/**
* {@inheritDoc}
*/
@@ -727,7 +727,7 @@ public class FastDateParser implements D
}
return true;
}
-
+
/**
* {@inheritDoc}
*/
@@ -735,14 +735,14 @@ public class FastDateParser implements D
public void setCalendar(FastDateParser parser, Calendar cal, String value) {
cal.set(field, modify(Integer.parseInt(value)));
}
-
+
/**
- * Make any modifications to parsed integer
+ * Make any modifications to parsed integer
* @param iValue The parsed integer
* @return The modified value
*/
public int modify(int iValue) {
- return iValue;
+ return iValue;
}
}
@@ -759,7 +759,7 @@ public class FastDateParser implements D
cal.set(Calendar.YEAR, iValue);
}
};
-
+
/**
* A strategy that handles a timezone field in the parsing pattern
*/
@@ -767,7 +767,7 @@ public class FastDateParser implements D
final String validTimeZoneChars;
final SortedMap<String, TimeZone> tzNames= new TreeMap<String, TimeZone>(String.CASE_INSENSITIVE_ORDER);
-
+
/**
* Construct a Strategy that parses a TimeZone
* @param locale The Locale
@@ -786,7 +786,7 @@ public class FastDateParser implements D
}
}
StringBuilder sb= new StringBuilder();
- sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
+ sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
for(String id : tzNames.keySet()) {
escapeRegex(sb, id, false).append('|');
}
@@ -830,7 +830,7 @@ public class FastDateParser implements D
}
}
cal.setTimeZone(tz);
- }
+ }
}
@@ -838,11 +838,11 @@ public class FastDateParser implements D
private static final Strategy DAY_OF_WEEK_STRATEGY = new TextStrategy(Calendar.DAY_OF_WEEK);
private static final Strategy AM_PM_STRATEGY = new TextStrategy(Calendar.AM_PM);
private static final Strategy TEXT_MONTH_STRATEGY = new TextStrategy(Calendar.MONTH);
-
+
private static final Strategy NUMBER_MONTH_STRATEGY = new NumberStrategy(Calendar.MONTH) {
@Override
public int modify(int iValue) {
- return iValue-1;
+ return iValue-1;
}
};
private static final Strategy LITERAL_YEAR_STRATEGY = new NumberStrategy(Calendar.YEAR);
@@ -855,13 +855,13 @@ public class FastDateParser implements D
private static final Strategy MODULO_HOUR_OF_DAY_STRATEGY = new NumberStrategy(Calendar.HOUR_OF_DAY) {
@Override
public int modify(int iValue) {
- return iValue%24;
+ return iValue%24;
}
};
private static final Strategy MODULO_HOUR_STRATEGY = new NumberStrategy(Calendar.HOUR) {
@Override
public int modify(int iValue) {
- return iValue%12;
+ return iValue%12;
}
};
private static final Strategy HOUR_STRATEGY = new NumberStrategy(Calendar.HOUR);
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java?rev=1390722&r1=1390721&r2=1390722&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java Wed Sep 26 20:44:16 2012
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -82,7 +82,7 @@ public class FastDateParserTest {
}
@Test
- public void test_Equality_Hash() {
+ public void test_Equality_Hash() {
DateParser[] parsers= {
getInstance(yMdHmsSZ, NEW_YORK, Locale.US),
getInstance(DMY_DOT, NEW_YORK, Locale.US),
@@ -92,17 +92,17 @@ public class FastDateParserTest {
getInstance(MDY_SLASH, REYKJAVIK, Locale.US),
getInstance(MDY_SLASH, REYKJAVIK, SWEDEN)
};
-
+
Map<DateParser,Integer> map= new HashMap<DateParser,Integer>();
int i= 0;
for(DateParser parser:parsers) {
- map.put(parser, Integer.valueOf(i++));
+ map.put(parser, Integer.valueOf(i++));
}
i= 0;
for(DateParser parser:parsers) {
assertEquals(i++, map.get(parser).intValue());
- }
+ }
}
@Test
@@ -110,64 +110,64 @@ public class FastDateParserTest {
Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 6, 10, 16, 33, 20);
-
+
DateParser fdf = getInstance(yMdHmsSZ, NEW_YORK, Locale.US);
-
+
assertEquals(cal.getTime(), fdf.parse("2003-07-10T15:33:20.000 -0500"));
assertEquals(cal.getTime(), fdf.parse("2003-07-10T15:33:20.000 GMT-05:00"));
assertEquals(cal.getTime(), fdf.parse("2003-07-10T16:33:20.000 Eastern Daylight Time"));
assertEquals(cal.getTime(), fdf.parse("2003-07-10T16:33:20.000 EDT"));
-
+
cal.setTimeZone(TimeZone.getTimeZone("GMT-3"));
cal.set(2003, 1, 10, 9, 0, 0);
-
+
assertEquals(cal.getTime(), fdf.parse("2003-02-10T09:00:00.000 -0300"));
-
+
cal.setTimeZone(TimeZone.getTimeZone("GMT+5"));
cal.set(2003, 1, 10, 15, 5, 6);
-
+
assertEquals(cal.getTime(), fdf.parse("2003-02-10T15:05:06.000 +0500"));
}
-
+
@Test
public void testParseLongShort() throws ParseException {
- Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
+ Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
cal.setTimeZone(NEW_YORK);
-
+
DateParser fdf = getInstance("yyyy GGGG MMMM dddd aaaa EEEE HHHH mmmm ssss SSSS ZZZZ", NEW_YORK, Locale.US);
-
+
assertEquals(cal.getTime(), fdf.parse("2003 AD February 0010 PM Monday 0015 0033 0020 0989 GMT-05:00"));
cal.set(Calendar.ERA, GregorianCalendar.BC);
-
+
Date parse = fdf.parse("2003 BC February 0010 PM Saturday 0015 0033 0020 0989 GMT-05:00");
assertEquals(cal.getTime(), parse);
-
+
fdf = getInstance("y G M d a E H m s S Z", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("03 BC 2 10 PM Sat 15 33 20 989 -0500"));
-
+
cal.set(Calendar.ERA, GregorianCalendar.AD);
assertEquals(cal.getTime(), fdf.parse("03 AD 2 10 PM Saturday 15 33 20 989 -0500"));
}
-
+
@Test
public void testAmPm() throws ParseException {
Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
-
- DateParser h = getInstance("yyyy-MM-dd hh a mm:ss", NEW_YORK, Locale.US);
- DateParser K = getInstance("yyyy-MM-dd KK a mm:ss", NEW_YORK, Locale.US);
- DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US);
- DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US);
+
+ DateParser h = getInstance("yyyy-MM-dd hh a mm:ss", NEW_YORK, Locale.US);
+ DateParser K = getInstance("yyyy-MM-dd KK a mm:ss", NEW_YORK, Locale.US);
+ DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US);
+ DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US);
cal.set(2010, 7, 1, 0, 33, 20);
assertEquals(cal.getTime(), h.parse("2010-08-01 12 AM 33:20"));
assertEquals(cal.getTime(), K.parse("2010-08-01 0 AM 33:20"));
assertEquals(cal.getTime(), k.parse("2010-08-01 00:33:20"));
assertEquals(cal.getTime(), H.parse("2010-08-01 00:33:20"));
-
+
cal.set(2010, 7, 1, 3, 33, 20);
assertEquals(cal.getTime(), h.parse("2010-08-01 3 AM 33:20"));
assertEquals(cal.getTime(), K.parse("2010-08-01 3 AM 33:20"));
@@ -216,7 +216,7 @@ public class FastDateParserTest {
String fmt = sdf.format(in);
try {
Date out = sdf.parse(fmt);
-
+
assertEquals(locale.toString()+" "+year+" "+ format+ " "+tz.getID(), in, out);
} catch (ParseException pe) {
System.out.println(fmt+" "+locale.toString()+" "+year+" "+ format+ " "+tz.getID());
@@ -269,7 +269,7 @@ public class FastDateParserTest {
}
private void testLocales(String format, boolean eraBC) throws Exception {
-
+
Calendar cal= Calendar.getInstance(GMT);
cal.clear();
cal.set(2003, 1, 10);
@@ -304,55 +304,55 @@ public class FastDateParserTest {
}
private void checkParse(Locale locale, Calendar cal, SimpleDateFormat sdf, DateParser fdf) throws ParseException {
- String formattedDate= sdf.format(cal.getTime());
+ String formattedDate= sdf.format(cal.getTime());
Date expectedTime = sdf.parse(formattedDate);
Date actualTime = fdf.parse(formattedDate);
assertEquals(locale.toString()+" "+formattedDate
+"\n",expectedTime, actualTime);
}
-
+
@Test
public void testParseNumerics() throws ParseException {
Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
-
+
DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("20030210153320989"));
}
-
+
@Test
public void testQuotes() throws ParseException {
Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10, 15, 33, 20);
cal.set(Calendar.MILLISECOND, 989);
-
+
DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("'20030210A'B153320989'"));
}
-
+
@Test
public void testDayOf() throws ParseException {
Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US);
cal.clear();
cal.set(2003, 1, 10);
-
+
DateParser fdf = getInstance("W w F D y", NEW_YORK, Locale.US);
assertEquals(cal.getTime(), fdf.parse("3 7 2 41 03"));
}
-
+
/**
* Test case for {@link FastDateParser#FastDateParser(String, TimeZone, Locale)}.
- * @throws ParseException
+ * @throws ParseException
*/
@Test
public void testShortDateStyleWithLocales() throws ParseException {
DateParser fdf = getDateInstance(FastDateFormat.SHORT, Locale.US);
Calendar cal = Calendar.getInstance();
cal.clear();
-
+
cal.set(2004, 1, 3);
assertEquals(cal.getTime(), fdf.parse("2/3/04"));
@@ -362,7 +362,7 @@ public class FastDateParserTest {
/**
* Tests that pre-1000AD years get padded with yyyy
- * @throws ParseException
+ * @throws ParseException
*/
@Test
public void testLowYearPadding() throws ParseException {
@@ -379,16 +379,16 @@ public class FastDateParserTest {
cal.set(999,0,1);
assertEquals(cal.getTime(), parser.parse("0999/01/01"));
}
-
+
/**
- * @throws ParseException
+ * @throws ParseException
*/
@Test
public void testMilleniumBug() throws ParseException {
DateParser parser = getInstance(DMY_DOT);
Calendar cal = Calendar.getInstance();
cal.clear();
-
+
cal.set(1000,0,1);
assertEquals(cal.getTime(), parser.parse("01.01.1000"));
}
@@ -408,22 +408,22 @@ public class FastDateParserTest {
@Test
public void testLang538() throws ParseException {
DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT);
-
+
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));
cal.clear();
cal.set(2009, 9, 16, 8, 42, 16);
assertEquals(cal.getTime(), parser.parse("2009-10-16T16:42:16.000Z"));
}
-
+
@Test
public void testEquals() {
DateParser parser1= getInstance(YMD_SLASH);
DateParser parser2= getInstance(YMD_SLASH);
- assertEquals(parser1, parser2);
+ assertEquals(parser1, parser2);
assertEquals(parser1.hashCode(), parser2.hashCode());
-
+
assertFalse(parser1.equals(new Object()));
}
@@ -432,19 +432,19 @@ public class FastDateParserTest {
DateParser parser= getInstance(YMD_SLASH);
assertTrue(parser.toString().startsWith("FastDate"));
}
-
+
@Test
public void testPatternMatches() {
DateParser parser= getInstance(yMdHmsSZ);
assertEquals(yMdHmsSZ, parser.getPattern());
}
-
+
@Test
public void testLocaleMatches() {
DateParser parser= getInstance(yMdHmsSZ, SWEDEN);
assertEquals(SWEDEN, parser.getLocale());
}
-
+
@Test
public void testTimeZoneMatches() {
DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK);