You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2017/06/08 08:15:51 UTC
[17/48] [lang] Make sure lines in files don't have trailing white
spaces and remove all trailing white spaces
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
index 74e81d6..7cb65f8 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
@@ -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.
@@ -34,7 +34,7 @@ public class EntityArraysTest {
public void testConstructorExists() {
new EntityArrays();
}
-
+
// LANG-659 - check arrays for duplicate entries
@Test
public void testHTML40_EXTENDED_ESCAPE(){
@@ -46,7 +46,7 @@ public class EntityArraysTest {
assertTrue("Already added entry 1: "+i+" "+sa[i][1],col1.add(sa[i][1]));
}
}
-
+
// LANG-658 - check arrays for duplicate entries
@Test
public void testISO8859_1_ESCAPE(){
@@ -57,7 +57,7 @@ public class EntityArraysTest {
for(int i =0; i <sa.length; i++){
final boolean add0 = col0.add(sa[i][0]);
final boolean add1 = col1.add(sa[i][1]);
- if (!add0) {
+ if (!add0) {
success = false;
System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]);
}
@@ -68,6 +68,6 @@ public class EntityArraysTest {
}
assertTrue("One or more errors detected",success);
}
-
-
+
+
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
index a53f777..e936878 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java
@@ -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.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
index 9c0594b..7db8fb7 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java
@@ -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.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
index 07c1841..18f81c6 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java
@@ -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.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
index cbe80f3..c879f5f 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java
@@ -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.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
index e5ca409..7006074 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java
@@ -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.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
index 5ab6752..a0ec693 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
@@ -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.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
index 457aa9b..fc89911 100644
--- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
@@ -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.
@@ -29,14 +29,14 @@ import org.junit.Test;
public class UnicodeUnpairedSurrogateRemoverTest {
final UnicodeUnpairedSurrogateRemover subject = new UnicodeUnpairedSurrogateRemover();
final CharArrayWriter writer = new CharArrayWriter(); // nothing is ever written to it
-
+
@Test
public void testValidCharacters() throws IOException {
assertEquals(false, subject.translate(0xd7ff, writer));
assertEquals(false, subject.translate(0xe000, writer));
assertEquals(0, writer.size());
}
-
+
@Test
public void testInvalidCharacters() throws IOException {
assertEquals(true, subject.translate(0xd800, writer));
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
index 0ae29ec..f197974 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
@@ -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.
@@ -42,7 +42,7 @@ public class DateFormatUtilsTest {
@Rule
public SystemDefaultsSwitch defaults = new SystemDefaultsSwitch();
-
+
//-----------------------------------------------------------------------
@Test
public void testConstructor() {
@@ -53,7 +53,7 @@ public class DateFormatUtilsTest {
assertTrue(Modifier.isPublic(DateFormatUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(DateFormatUtils.class.getModifiers()));
}
-
+
//-----------------------------------------------------------------------
@Test
public void testFormat() {
@@ -70,14 +70,14 @@ public class DateFormatUtilsTest {
buffer.append(day);
buffer.append(hour);
assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH"));
-
+
assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH"));
-
+
assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US));
-
+
assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH", Locale.US));
}
-
+
//-----------------------------------------------------------------------
@Test
public void testFormatCalendar() {
@@ -94,24 +94,24 @@ public class DateFormatUtilsTest {
buffer.append(day);
buffer.append(hour);
assertEquals(buffer.toString(), DateFormatUtils.format(c, "yyyyMdH"));
-
+
assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH"));
-
+
assertEquals(buffer.toString(), DateFormatUtils.format(c, "yyyyMdH", Locale.US));
-
+
assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US));
}
-
+
@Test
public void testFormatUTC() {
final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.set(2005, Calendar.JANUARY, 1, 12, 0, 0);
assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()));
-
+
assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()));
-
+
assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US));
-
+
assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US));
}
@@ -142,7 +142,7 @@ public class DateFormatUtilsTest {
final TimeZone timeZone = TimeZone.getTimeZone("UTC");
assertFormats(expectedValue, pattern, timeZone, createFebruaryTestDate(timeZone));
}
-
+
@Test
public void testDateTimeISO() throws Exception {
testGmtMinus3("2002-02-23T09:11:12", DateFormatUtils.ISO_DATETIME_FORMAT.getPattern());
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
index 519c9d2..7a9e114 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java
@@ -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.
@@ -44,7 +44,7 @@ public class DateUtilsFragmentTest {
aCalendar.set(Calendar.MILLISECOND, millis);
aDate = aCalendar.getTime();
}
-
+
@Test
public void testNullDate() {
try {
@@ -100,7 +100,7 @@ public class DateUtilsFragmentTest {
fail();
} catch(final IllegalArgumentException iae) {}
}
-
+
@Test
public void testInvalidFragmentWithDate() {
try {
@@ -174,7 +174,7 @@ public class DateUtilsFragmentTest {
assertEquals(0, DateUtils.getFragmentInHours(aCalendar, Calendar.MILLISECOND));
assertEquals(0, DateUtils.getFragmentInDays(aCalendar, Calendar.MILLISECOND));
}
-
+
@Test
public void testSecondFragmentInLargerUnitWithDate() {
assertEquals(0, DateUtils.getFragmentInSeconds(aDate, Calendar.SECOND));
@@ -190,7 +190,7 @@ public class DateUtilsFragmentTest {
assertEquals(0, DateUtils.getFragmentInHours(aCalendar, Calendar.SECOND));
assertEquals(0, DateUtils.getFragmentInDays(aCalendar, Calendar.SECOND));
}
-
+
@Test
public void testMinuteFragmentInLargerUnitWithDate() {
assertEquals(0, DateUtils.getFragmentInMinutes(aDate, Calendar.MINUTE));
@@ -238,7 +238,7 @@ public class DateUtilsFragmentTest {
}
//Calendar.SECOND as useful fragment
-
+
@Test
public void testMillisecondsOfSecondWithDate() {
final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND);
@@ -280,13 +280,13 @@ public class DateUtilsFragmentTest {
}
//Calendar.HOUR_OF_DAY as useful fragment
-
+
@Test
public void testMillisecondsOfHourWithDate() {
final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
}
-
+
@Test
public void testMillisecondsOfHourWithCalendar() {
final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY);
@@ -329,16 +329,16 @@ public class DateUtilsFragmentTest {
@Test
public void testMillisecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DATE);
- final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
+ final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
}
-
+
@Test
public void testMillisecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DATE);
- final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
+ final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@@ -365,7 +365,7 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfDayWithDate() {
long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE);
- final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
+ final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue,testResult);
testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue,testResult);
@@ -374,16 +374,16 @@ public class DateUtilsFragmentTest {
@Test
public void testMinutesOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DATE);
- final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
+ final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
}
-
+
@Test
public void testHoursOfDayWithDate() {
long testResult = DateUtils.getFragmentInHours(aDate, Calendar.DATE);
- final long expectedValue = hours;
+ final long expectedValue = hours;
assertEquals(expectedValue,testResult);
testResult = DateUtils.getFragmentInHours(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue,testResult);
@@ -392,13 +392,13 @@ public class DateUtilsFragmentTest {
@Test
public void testHoursOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DATE);
- final long expectedValue = hours;
+ final long expectedValue = hours;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
}
-
-
+
+
//Calendar.MONTH as useful fragment
@Test
public void testMillisecondsOfMonthWithDate() {
@@ -415,7 +415,7 @@ public class DateUtilsFragmentTest {
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY),
testResult);
}
-
+
@Test
public void testSecondsOfMonthWithDate() {
final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH);
@@ -470,7 +470,7 @@ testResult);
/ DateUtils.MILLIS_PER_HOUR,
testResult);
}
-
+
//Calendar.YEAR as useful fragment
@Test
public void testMillisecondsOfYearWithDate() {
@@ -489,7 +489,7 @@ testResult);
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY),
testResult);
}
-
+
@Test
public void testSecondsOfYearWithDate() {
final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR);
@@ -563,27 +563,27 @@ testResult);
/ DateUtils.MILLIS_PER_HOUR,
testResult);
}
-
+
@Test
public void testDaysOfMonthWithCalendar() throws Exception {
final long testResult = DateUtils.getFragmentInDays(aCalendar, Calendar.MONTH);
assertEquals(days, testResult);
}
-
+
@Test
public void testDaysOfMonthWithDate() throws Exception {
final long testResult = DateUtils.getFragmentInDays(aDate, Calendar.MONTH);
final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(cal.get(Calendar.DAY_OF_MONTH), testResult);
- }
-
+ }
+
@Test
public void testDaysOfYearWithCalendar() throws Exception {
final long testResult = DateUtils.getFragmentInDays(aCalendar, Calendar.YEAR);
assertEquals(aCalendar.get(Calendar.DAY_OF_YEAR), testResult);
}
-
+
@Test
public void testDaysOfYearWithDate() throws Exception {
final long testResult = DateUtils.getFragmentInDays(aDate, Calendar.YEAR);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
index b2a169b..432a574 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java
@@ -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.
@@ -31,19 +31,19 @@ import java.util.Locale;
/**
* These Unit-tests will check all possible extremes when using some rounding-methods of DateUtils.
* The extremes are tested at the switch-point in milliseconds
- *
+ *
* According to the implementation SEMI_MONTH will either round/truncate to the 1st or 16th
* When rounding Calendar.MONTH it depends on the number of days within that month.
* A month with 28 days will be rounded up from the 15th
* A month with 29 or 30 days will be rounded up from the 16th
* A month with 31 days will be rounded up from the 17th
- *
+ *
* @since 3.0
*/
public class DateUtilsRoundingTest {
DateFormat dateTimeParser;
-
+
Date januaryOneDate;
Date targetYearDate;
//No targetMonths, these must be tested for every type of month(28-31 days)
@@ -62,7 +62,7 @@ public class DateUtilsRoundingTest {
public void setUp() throws Exception {
dateTimeParser = new SimpleDateFormat("MMM dd, yyyy H:mm:ss.SSS", Locale.ENGLISH);
-
+
targetYearDate = dateTimeParser.parse("January 1, 2007 0:00:00.000");
targetDateDate = targetDayOfMonthDate = dateTimeParser.parse("June 1, 2008 0:00:00.000");
targetAmDate = dateTimeParser.parse("June 1, 2008 0:00:00.000");
@@ -72,7 +72,7 @@ public class DateUtilsRoundingTest {
targetMinuteDate = dateTimeParser.parse("June 1, 2008 8:15:00.000");
targetSecondDate = dateTimeParser.parse("June 1, 2008 8:15:14.000");
targetMilliSecondDate = dateTimeParser.parse("June 1, 2008 8:15:14.231");
-
+
januaryOneDate = dateTimeParser.parse("January 1, 2008 0:00:00.000");
januaryOneCalendar = Calendar.getInstance();
januaryOneCalendar.setTime(januaryOneDate);
@@ -80,7 +80,7 @@ public class DateUtilsRoundingTest {
/**
* Tests DateUtils.round()-method with Calendar.Year
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -92,12 +92,12 @@ public class DateUtilsRoundingTest {
final Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.MONTH
* Includes rounding months with 28, 29, 30 and 31 days
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -106,7 +106,7 @@ public class DateUtilsRoundingTest {
final int calendarField = Calendar.MONTH;
Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
Date minDate, maxDate;
-
+
//month with 28 days
roundedUpDate = dateTimeParser.parse("March 1, 2007 0:00:00.000");
roundedDownDate = dateTimeParser.parse("February 1, 2007 0:00:00.000");
@@ -118,30 +118,30 @@ public class DateUtilsRoundingTest {
roundedDownDate = dateTimeParser.parse("February 1, 2008 0:00:00.000");
lastRoundedDownDate = dateTimeParser.parse("February 15, 2008 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//month with 30 days
roundedUpDate = dateTimeParser.parse("May 1, 2008 0:00:00.000");
roundedDownDate = dateTimeParser.parse("April 1, 2008 0:00:00.000");
lastRoundedDownDate = dateTimeParser.parse("April 15, 2008 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//month with 31 days
roundedUpDate = dateTimeParser.parse("June 1, 2008 0:00:00.000");
roundedDownDate = dateTimeParser.parse("May 1, 2008 0:00:00.000");
lastRoundedDownDate = dateTimeParser.parse("May 16, 2008 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 17, 2007 00:00:00.000");
maxDate = dateTimeParser.parse("January 16, 2008 23:59:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with DateUtils.SEMI_MONTH
- * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half
+ * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -150,7 +150,7 @@ public class DateUtilsRoundingTest {
final int calendarField = DateUtils.SEMI_MONTH;
Date roundedUpDate, roundedDownDate, lastRoundedDownDate;
Date minDate, maxDate;
-
+
//month with 28 days (1)
roundedUpDate = dateTimeParser.parse("February 16, 2007 0:00:00.000");
roundedDownDate = dateTimeParser.parse("February 1, 2007 0:00:00.000");
@@ -168,7 +168,7 @@ public class DateUtilsRoundingTest {
roundedDownDate = dateTimeParser.parse("February 1, 2008 0:00:00.000");
lastRoundedDownDate = dateTimeParser.parse("February 8, 2008 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//month with 29 days (2)
roundedUpDate = dateTimeParser.parse("March 1, 2008 0:00:00.000");
roundedDownDate = dateTimeParser.parse("February 16, 2008 0:00:00.000");
@@ -186,7 +186,7 @@ public class DateUtilsRoundingTest {
roundedDownDate = dateTimeParser.parse("April 16, 2008 0:00:00.000");
lastRoundedDownDate = dateTimeParser.parse("April 23, 2008 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//month with 31 days (1)
roundedUpDate = dateTimeParser.parse("May 16, 2008 0:00:00.000");
roundedDownDate = dateTimeParser.parse("May 1, 2008 0:00:00.000");
@@ -198,18 +198,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = dateTimeParser.parse("May 16, 2008 0:00:00.000");
lastRoundedDownDate = dateTimeParser.parse("May 23, 2008 23:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 24, 2007 00:00:00.000");
maxDate = dateTimeParser.parse("January 8, 2008 23:59:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.DATE
- * Includes rounding the extremes of one day
+ * Includes rounding the extremes of one day
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -223,18 +223,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = targetDateDate;
lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 11:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 31, 2007 12:00:00.000");
maxDate = dateTimeParser.parse("January 1, 2008 11:59:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.DAY_OF_MONTH
- * Includes rounding the extremes of one day
+ * Includes rounding the extremes of one day
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -248,18 +248,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = targetDayOfMonthDate;
lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 11:59:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 31, 2007 12:00:00.000");
maxDate = dateTimeParser.parse("January 1, 2008 11:59:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.AM_PM
- * Includes rounding the extremes of both AM and PM of one day
+ * Includes rounding the extremes of both AM and PM of one day
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -286,12 +286,12 @@ public class DateUtilsRoundingTest {
maxDate = dateTimeParser.parse("January 1, 2008 5:59:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.HOUR_OF_DAY
- * Includes rounding the extremes of one hour
+ * Includes rounding the extremes of one hour
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -305,18 +305,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = targetHourOfDayDate;
lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:29:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 31, 2007 23:30:00.000");
maxDate = dateTimeParser.parse("January 1, 2008 0:29:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.HOUR
- * Includes rounding the extremes of one hour
+ * Includes rounding the extremes of one hour
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -330,18 +330,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = targetHourDate;
lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:29:59.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 31, 2007 23:30:00.000");
maxDate = dateTimeParser.parse("January 1, 2008 0:29:59.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.MINUTE
- * Includes rounding the extremes of one minute
+ * Includes rounding the extremes of one minute
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -355,18 +355,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = targetMinuteDate;
lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:15:29.999");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 31, 2007 23:59:30.000");
maxDate = dateTimeParser.parse("January 1, 2008 0:00:29.999");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.SECOND
- * Includes rounding the extremes of one second
+ * Includes rounding the extremes of one second
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -380,18 +380,18 @@ public class DateUtilsRoundingTest {
roundedDownDate = targetSecondDate;
lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:15:14.499");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = dateTimeParser.parse("December 31, 2007 23:59:59.500");
maxDate = dateTimeParser.parse("January 1, 2008 0:00:00.499");
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Tests DateUtils.round()-method with Calendar.MILLISECOND
- * Includes rounding the extremes of one second
+ * Includes rounding the extremes of one second
* Includes rounding to January 1
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -404,15 +404,15 @@ public class DateUtilsRoundingTest {
roundedDownDate = lastRoundedDownDate = targetMilliSecondDate;
roundedUpDate = dateTimeParser.parse("June 1, 2008 8:15:14.232");
baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField);
-
+
//round to January 1
minDate = maxDate = januaryOneDate;
roundToJanuaryFirst(minDate, maxDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.YEAR
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -425,7 +425,7 @@ public class DateUtilsRoundingTest {
/**
* Test DateUtils.truncate()-method with Calendar.MONTH
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -440,7 +440,7 @@ public class DateUtilsRoundingTest {
/**
* Test DateUtils.truncate()-method with DateUtils.SEMI_MONTH
* Includes truncating months with 28, 29, 30 and 31 days, each with first and second half
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -448,7 +448,7 @@ public class DateUtilsRoundingTest {
public void testTruncateSemiMonth() throws Exception {
final int calendarField = DateUtils.SEMI_MONTH;
Date truncatedDate, lastTruncateDate;
-
+
//month with 28 days (1)
truncatedDate = dateTimeParser.parse("February 1, 2007 0:00:00.000");
lastTruncateDate = dateTimeParser.parse("February 15, 2007 23:59:59.999");
@@ -478,7 +478,7 @@ public class DateUtilsRoundingTest {
truncatedDate = dateTimeParser.parse("April 16, 2008 0:00:00.000");
lastTruncateDate = dateTimeParser.parse("April 30, 2008 23:59:59.999");
baseTruncateTest(truncatedDate, lastTruncateDate, calendarField);
-
+
//month with 31 days (1)
truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000");
lastTruncateDate = dateTimeParser.parse("March 15, 2008 23:59:59.999");
@@ -493,7 +493,7 @@ public class DateUtilsRoundingTest {
/**
* Test DateUtils.truncate()-method with Calendar.DATE
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -503,10 +503,10 @@ public class DateUtilsRoundingTest {
final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetDateDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.DAY_OF_MONTH
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -516,18 +516,18 @@ public class DateUtilsRoundingTest {
final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetDayOfMonthDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.AM_PM
- * Includes truncating the extremes of both AM and PM of one day
- *
+ * Includes truncating the extremes of both AM and PM of one day
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@Test
public void testTruncateAmPm() throws Exception {
final int calendarField = Calendar.AM_PM;
-
+
//AM
Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 11:59:59.999");
baseTruncateTest(targetAmDate, lastTruncateDate, calendarField);
@@ -536,10 +536,10 @@ public class DateUtilsRoundingTest {
lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999");
baseTruncateTest(targetPmDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.HOUR
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -549,10 +549,10 @@ public class DateUtilsRoundingTest {
final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
baseTruncateTest(targetHourDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.HOUR_OF_DAY
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -562,10 +562,10 @@ public class DateUtilsRoundingTest {
final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999");
baseTruncateTest(targetHourOfDayDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.MINUTE
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -575,10 +575,10 @@ public class DateUtilsRoundingTest {
final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999");
baseTruncateTest(targetMinuteDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.SECOND
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -588,10 +588,10 @@ public class DateUtilsRoundingTest {
final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999");
baseTruncateTest(targetSecondDate, lastTruncateDate, calendarField);
}
-
+
/**
* Test DateUtils.truncate()-method with Calendar.SECOND
- *
+ *
* @throws Exception so we don't have to catch it
* @since 3.0
*/
@@ -600,13 +600,13 @@ public class DateUtilsRoundingTest {
final int calendarField = Calendar.MILLISECOND;
baseTruncateTest(targetMilliSecondDate, targetMilliSecondDate, calendarField);
}
-
+
/**
- * When using this basetest all extremes are tested.<br>
+ * When using this basetest all extremes are tested.<br>
* It will test the Date, Calendar and Object-implementation<br>
* lastRoundDownDate should round down to roundedDownDate<br>
* lastRoundDownDate + 1 millisecond should round up to roundedUpDate
- *
+ *
* @param roundedUpDate the next rounded date after <strong>roundedDownDate</strong> when using <strong>calendarField</strong>
* @param roundedDownDate the result if <strong>lastRoundDownDate</strong> was rounded with <strong>calendarField</strong>
* @param lastRoundDownDate rounding this value with <strong>calendarField</strong> will result in <strong>roundedDownDate</strong>
@@ -615,15 +615,15 @@ public class DateUtilsRoundingTest {
*/
protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) {
final Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1);
-
+
//Date-comparison
assertEquals(roundedDownDate, DateUtils.round(roundedDownDate, calendarField));
assertEquals(roundedUpDate, DateUtils.round(roundedUpDate, calendarField));
assertEquals(roundedDownDate, DateUtils.round(lastRoundDownDate, calendarField));
assertEquals(roundedUpDate, DateUtils.round(firstRoundUpDate, calendarField));
-
+
//Calendar-initiations
- Calendar roundedUpCalendar, roundedDownCalendar, lastRoundDownCalendar, firstRoundUpCalendar;
+ Calendar roundedUpCalendar, roundedDownCalendar, lastRoundDownCalendar, firstRoundUpCalendar;
roundedDownCalendar = Calendar.getInstance();
roundedUpCalendar = Calendar.getInstance();
lastRoundDownCalendar = Calendar.getInstance();
@@ -649,13 +649,13 @@ public class DateUtilsRoundingTest {
assertEquals(roundedDownDate, DateUtils.round((Object) lastRoundDownDate, calendarField));
assertEquals(roundedUpDate, DateUtils.round((Object) firstRoundUpDate, calendarField));
}
-
+
/**
- * When using this basetest all extremes are tested.<br>
+ * When using this basetest all extremes are tested.<br>
* It will test the Date, Calendar and Object-implementation<br>
* lastTruncateDate should round down to truncatedDate<br>
* lastTruncateDate + 1 millisecond should never round down to truncatedDate
- *
+ *
* @param truncatedDate expected Date when <strong>lastTruncateDate</strong> is truncated with <strong>calendarField</strong>
* @param lastTruncateDate the last possible Date which will truncate to <strong>truncatedDate</strong> with <strong>calendarField</strong>
* @param calendarField a Calendar.field value
@@ -663,14 +663,14 @@ public class DateUtilsRoundingTest {
*/
protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncateDate, final int calendarField) {
final Date nextTruncateDate = DateUtils.addMilliseconds(lastTruncateDate, 1);
-
+
//Date-comparison
assertEquals("Truncating "+ fdf.format(truncatedDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", truncatedDate, DateUtils.truncate(truncatedDate, calendarField));
assertEquals(truncatedDate, DateUtils.truncate(lastTruncateDate, calendarField));
assertFalse(fdf.format(lastTruncateDate) +" is not an extreme when truncating as Date with CalendarField-value "+ calendarField, truncatedDate.equals(DateUtils.truncate(nextTruncateDate, calendarField)));
-
+
//Calendar-initiations
- Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar;
+ Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar;
truncatedCalendar = Calendar.getInstance();
lastTruncateCalendar = Calendar.getInstance();
nextTruncateCalendar = Calendar.getInstance();
@@ -691,12 +691,12 @@ public class DateUtilsRoundingTest {
assertEquals(truncatedDate, DateUtils.truncate((Object) lastTruncateCalendar, calendarField));
assertFalse(fdf.format(lastTruncateCalendar) +" is not an extreme when truncating as Calendar cast to Object with CalendarField-value "+ calendarField, truncatedDate.equals(DateUtils.truncate((Object) nextTruncateCalendar, calendarField)));
}
-
+
/**
- *
+ *
* Any January 1 could be considered as the ultimate extreme.
- * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first.
- *
+ * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first.
+ *
* @param minDate the lower bound
* @param maxDate the upper bound
* @param calendarField a Calendar.field value
@@ -706,7 +706,7 @@ public class DateUtilsRoundingTest {
assertEquals("Rounding "+ fdf.format(januaryOneDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", januaryOneDate, DateUtils.round(januaryOneDate, calendarField));
assertEquals(januaryOneDate, DateUtils.round(minDate, calendarField));
assertEquals(januaryOneDate, DateUtils.round(maxDate, calendarField));
-
+
final Calendar minCalendar = Calendar.getInstance();
minCalendar.setTime(minDate);
final Calendar maxCalendar = Calendar.getInstance();
@@ -719,7 +719,7 @@ public class DateUtilsRoundingTest {
final Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1);
assertFalse(fdf.format(minDate) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField)));
assertFalse(fdf.format(maxDate) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField)));
-
+
final Calendar toPrevRoundCalendar = Calendar.getInstance();
toPrevRoundCalendar.setTime(toPrevRoundDate);
final Calendar toNextRoundCalendar = Calendar.getInstance();
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
index 964c40b..77e1101 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -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.
@@ -59,7 +59,7 @@ public class DateUtilsTest {
@Rule
public SystemDefaultsSwitch defaults = new SystemDefaultsSwitch();
-
+
private DateFormat dateParser = null;
private DateFormat dateTimeParser = null;
private Date dateAmPm1 = null;
@@ -152,7 +152,7 @@ public class DateUtilsTest {
assertTrue(Modifier.isPublic(DateUtils.class.getModifiers()));
assertFalse(Modifier.isFinal(DateUtils.class.getModifiers()));
}
-
+
//-----------------------------------------------------------------------
@Test
public void testIsSameDay_Date() {
@@ -250,7 +250,7 @@ public class DateUtilsTest {
calb.set(2004, Calendar.JULY, 9, 13, 45, 0);
calb.set(Calendar.MILLISECOND, 0);
assertFalse(DateUtils.isSameInstant(cala, calb));
-
+
calb.set(2004, Calendar.JULY, 9, 11, 45, 0);
assertTrue(DateUtils.isSameInstant(cala, calb));
}
@@ -288,7 +288,7 @@ public class DateUtilsTest {
calc.set(Calendar.MILLISECOND, 0);
cald.set(Calendar.MILLISECOND, 0);
assertFalse("LANG-677", DateUtils.isSameLocalTime(calc, cald));
-
+
calb.set(2004, Calendar.JULY, 9, 11, 45, 0);
assertFalse(DateUtils.isSameLocalTime(cala, calb));
}
@@ -316,11 +316,11 @@ public class DateUtilsTest {
final String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"};
Date date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
-
+
dateStr = "1972-338";
date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
-
+
dateStr = "19721203";
date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
@@ -348,7 +348,7 @@ public class DateUtilsTest {
public void testParse_NullParsers() throws Exception {
DateUtils.parseDate("19721203", (String[]) null);
}
-
+
@Test(expected = ParseException.class)
public void testParse_EmptyParsers() throws Exception {
DateUtils.parseDate("19721203");
@@ -360,10 +360,10 @@ public class DateUtilsTest {
final GregorianCalendar cal = new GregorianCalendar(1998, 6, 30);
final String dateStr = "02 942, 1996";
final String[] parsers = new String[] {"MM DDD, yyyy"};
-
+
final Date date = DateUtils.parseDate(dateStr, parsers);
assertEquals(cal.getTime(), date);
-
+
try {
DateUtils.parseDateStrictly(dateStr, parsers);
fail();
@@ -377,12 +377,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addYears(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2001, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addYears(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -396,12 +396,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addMonths(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 7, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addMonths(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -415,12 +415,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addWeeks(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 12, 4, 3, 2, 1);
-
+
result = DateUtils.addWeeks(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); // july
@@ -434,12 +434,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addDays(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 6, 4, 3, 2, 1);
-
+
result = DateUtils.addDays(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -453,12 +453,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addHours(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 5, 3, 2, 1);
-
+
result = DateUtils.addHours(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -472,12 +472,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addMinutes(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 4, 2, 1);
-
+
result = DateUtils.addMinutes(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -491,12 +491,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addSeconds(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 3, 1);
-
+
result = DateUtils.addSeconds(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -510,12 +510,12 @@ public class DateUtilsTest {
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 1);
-
+
result = DateUtils.addMilliseconds(BASE_DATE, 1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
assertDate(result, 2000, 6, 5, 4, 3, 2, 2);
-
+
result = DateUtils.addMilliseconds(BASE_DATE, -1);
assertNotSame(BASE_DATE, result);
assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1);
@@ -691,19 +691,19 @@ public class DateUtilsTest {
// expected
}
}
-
+
//-----------------------------------------------------------------------
@Test(expected=NullPointerException.class)
public void testToCalendarWithDateNull() {
DateUtils.toCalendar(null, zone);
}
-
+
//-----------------------------------------------------------------------
@Test(expected=NullPointerException.class)
public void testToCalendarWithTimeZoneNull() {
DateUtils.toCalendar(date1, null);
}
-
+
//-----------------------------------------------------------------------
@Test
public void testToCalendarWithDateAndTimeZoneNotNull() {
@@ -711,7 +711,7 @@ public class DateUtilsTest {
assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date2, c.getTime());
assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", defaultZone, c.getTimeZone());
}
-
+
//-----------------------------------------------------------------------
@Test(expected=NullPointerException.class)
public void testToCalendarWithDateAndTimeZoneNull() {
@@ -748,8 +748,8 @@ public class DateUtilsTest {
assertEquals("round semimonth-2 failed",
dateParser.parse("November 16, 2001"),
DateUtils.round(date2, DateUtils.SEMI_MONTH));
-
-
+
+
assertEquals("round date-1 failed",
dateParser.parse("February 13, 2002"),
DateUtils.round(date1, Calendar.DATE));
@@ -882,7 +882,7 @@ public class DateUtilsTest {
assertEquals("round ampm-4 failed",
dateTimeParser.parse("February 4, 2002 00:00:00.000"),
DateUtils.round((Object) calAmPm4, Calendar.AM_PM));
-
+
// Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 / LANG-13
// Test rounding across the beginning of daylight saving time
TimeZone.setDefault(zone);
@@ -911,7 +911,7 @@ public class DateUtilsTest {
assertEquals("round MET date across DST change-over",
dateTimeParser.parse("March 30, 2003 00:00:00.000"),
DateUtils.round((Object) cal7, Calendar.DATE));
-
+
assertEquals("round MET date across DST change-over",
dateTimeParser.parse("March 30, 2003 01:00:00.000"),
DateUtils.round(date4, Calendar.HOUR_OF_DAY));
@@ -1123,14 +1123,14 @@ public class DateUtilsTest {
assertEquals("truncate ampm-4 failed",
dateTimeParser.parse("February 3, 2002 12:00:00.000"),
DateUtils.truncate((Object) dateAmPm4, Calendar.AM_PM));
-
+
assertEquals("truncate calendar second-1 failed",
dateTimeParser.parse("February 12, 2002 12:34:56.000"),
DateUtils.truncate((Object) cal1, Calendar.SECOND));
assertEquals("truncate calendar second-2 failed",
dateTimeParser.parse("November 18, 2001 1:23:11.000"),
DateUtils.truncate((Object) cal2, Calendar.SECOND));
-
+
assertEquals("truncate ampm-1 failed",
dateTimeParser.parse("February 3, 2002 00:00:00.000"),
DateUtils.truncate((Object) calAmPm1, Calendar.AM_PM));
@@ -1143,7 +1143,7 @@ public class DateUtilsTest {
assertEquals("truncate ampm-4 failed",
dateTimeParser.parse("February 3, 2002 12:00:00.000"),
DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM));
-
+
try {
DateUtils.truncate((Date) null, Calendar.SECOND);
fail();
@@ -1180,7 +1180,7 @@ public class DateUtilsTest {
DateUtils.truncate((Object) cal8, Calendar.DATE));
TimeZone.setDefault(defaultZone);
dateTimeParser.setTimeZone(defaultZone);
-
+
// Bug 31395, large dates
final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
final GregorianCalendar endCal = new GregorianCalendar();
@@ -1214,7 +1214,7 @@ public class DateUtilsTest {
final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z");
format.setTimeZone(MST_MDT);
- final Date oct31_01MDT = new Date(1099206000000L);
+ final Date oct31_01MDT = new Date(1099206000000L);
final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
@@ -1284,9 +1284,9 @@ public class DateUtilsTest {
final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d);
final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
// the format loses milliseconds so have to reintroduce them
- assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000);
+ assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000);
}
-
+
/**
* Tests various values with the ceiling method
*
@@ -1361,7 +1361,7 @@ public class DateUtilsTest {
assertEquals("ceiling ampm-4 failed",
dateTimeParser.parse("February 4, 2002 00:00:00.000"),
DateUtils.ceiling(dateAmPm4, Calendar.AM_PM));
-
+
// tests public static Date ceiling(Object date, int field)
assertEquals("ceiling year-1 failed",
dateParser.parse("January 1, 2003"),
@@ -1417,14 +1417,14 @@ public class DateUtilsTest {
assertEquals("ceiling ampm-4 failed",
dateTimeParser.parse("February 4, 2002 00:00:00.000"),
DateUtils.ceiling((Object) dateAmPm4, Calendar.AM_PM));
-
+
assertEquals("ceiling calendar second-1 failed",
dateTimeParser.parse("February 12, 2002 12:34:57.000"),
DateUtils.ceiling((Object) cal1, Calendar.SECOND));
assertEquals("ceiling calendar second-2 failed",
dateTimeParser.parse("November 18, 2001 1:23:12.000"),
DateUtils.ceiling((Object) cal2, Calendar.SECOND));
-
+
assertEquals("ceiling ampm-1 failed",
dateTimeParser.parse("February 3, 2002 12:00:00.000"),
DateUtils.ceiling((Object) calAmPm1, Calendar.AM_PM));
@@ -1459,7 +1459,7 @@ public class DateUtilsTest {
fail();
} catch(final IllegalArgumentException ex) {}
-
+
// Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560
// Test ceiling across the beginning of daylight saving time
TimeZone.setDefault(zone);
@@ -1489,7 +1489,7 @@ public class DateUtilsTest {
assertEquals("ceiling MET date across DST change-over",
dateTimeParser.parse("March 31, 2003 00:00:00.000"),
DateUtils.ceiling((Object) cal7, Calendar.DATE));
-
+
assertEquals("ceiling MET date across DST change-over",
dateTimeParser.parse("March 30, 2003 03:00:00.000"),
DateUtils.ceiling(date4, Calendar.HOUR_OF_DAY));
@@ -1516,7 +1516,7 @@ public class DateUtilsTest {
DateUtils.ceiling((Object) cal7, Calendar.HOUR_OF_DAY));
TimeZone.setDefault(defaultZone);
dateTimeParser.setTimeZone(defaultZone);
-
+
// Bug 31395, large dates
final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis
final GregorianCalendar endCal = new GregorianCalendar();
@@ -1584,7 +1584,7 @@ public class DateUtilsTest {
}
final Calendar centered = DateUtils.truncate(now, Calendar.DATE);
centered.add(Calendar.DATE, -3);
-
+
Iterator<?> it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY);
assertWeekIterator(it, sunday);
it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_MONDAY);
@@ -1593,7 +1593,7 @@ public class DateUtilsTest {
assertWeekIterator(it, today);
it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER);
assertWeekIterator(it, centered);
-
+
it = DateUtils.iterator((Object) now, DateUtils.RANGE_WEEK_CENTER);
assertWeekIterator(it, centered);
it = DateUtils.iterator((Object) now.getTime(), DateUtils.RANGE_WEEK_CENTER);
@@ -1607,11 +1607,11 @@ public class DateUtilsTest {
try {
it.remove();
} catch( final UnsupportedOperationException ex) {}
-
+
now.add(Calendar.DATE,1);
}
}
-
+
/**
* Tests the calendar iterator for month-based ranges
*
@@ -1667,14 +1667,14 @@ public class DateUtilsTest {
public void testLANG799_DE_FAIL() throws ParseException {
DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz");
}
-
+
// Parse German date with English Locale, specifying German Locale override
@SystemDefaults(locale="en")
@Test
public void testLANG799_EN_WITH_DE_LOCALE() throws ParseException {
DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", Locale.GERMAN, "EEE, dd MMM yyyy HH:mm:ss zzz");
}
-
+
/**
* This checks that this is a 7 element iterator of Calendar objects
* that are dates (no time), and exactly 1 day spaced after each other.
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
index 2847c6d..b5eb0fa 100644
--- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
@@ -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.
@@ -409,14 +409,14 @@ public class DurationFormatUtilsTest {
// http://issues.apache.org/bugzilla/show_bug.cgi?id=38401
@Test
public void testBugzilla38401() {
- assertEqualDuration( "0000/00/30 16:00:00 000", new int[] { 2006, 0, 26, 18, 47, 34 },
+ assertEqualDuration( "0000/00/30 16:00:00 000", new int[] { 2006, 0, 26, 18, 47, 34 },
new int[] { 2006, 1, 26, 10, 47, 34 }, "yyyy/MM/dd HH:mm:ss SSS");
}
// https://issues.apache.org/jira/browse/LANG-281
@Test
public void testJiraLang281() {
- assertEqualDuration( "09", new int[] { 2005, 11, 31, 0, 0, 0 },
+ assertEqualDuration( "09", new int[] { 2005, 11, 31, 0, 0, 0 },
new int[] { 2006, 9, 6, 0, 0, 0 }, "MM");
}
@@ -438,7 +438,7 @@ public class DurationFormatUtilsTest {
for(int hr=0; hr < 24; hr++) {
for(int min=0; min < 60; min++) {
for(int sec=0; sec < 60; sec++) {
- assertEqualDuration( hr + ":" + min + ":" + sec,
+ assertEqualDuration( hr + ":" + min + ":" + sec,
new int[] { 2000, 0, 1, 0, 0, 0, 0 },
new int[] { 2000, 0, 1, hr, min, sec },
"H:m:s"
@@ -453,92 +453,92 @@ public class DurationFormatUtilsTest {
public void testEdgeDurations() {
// This test case must use a time zone without DST
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- assertEqualDuration( "01", new int[] { 2006, 0, 15, 0, 0, 0 },
+ assertEqualDuration( "01", new int[] { 2006, 0, 15, 0, 0, 0 },
new int[] { 2006, 2, 10, 0, 0, 0 }, "MM");
- assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 },
+ assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 },
new int[] { 2006, 0, 15, 0, 0, 0 }, "MM");
- assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 },
+ assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 },
new int[] { 2006, 0, 16, 0, 0, 0 }, "MM");
- assertEqualDuration( "11", new int[] { 2005, 0, 15, 0, 0, 0 },
+ assertEqualDuration( "11", new int[] { 2005, 0, 15, 0, 0, 0 },
new int[] { 2006, 0, 14, 0, 0, 0 }, "MM");
-
+
assertEqualDuration( "01 26", new int[] { 2006, 0, 15, 0, 0, 0 },
new int[] { 2006, 2, 10, 0, 0, 0 }, "MM dd");
assertEqualDuration( "54", new int[] { 2006, 0, 15, 0, 0, 0 },
- new int[] { 2006, 2, 10, 0, 0, 0 }, "dd");
-
+ new int[] { 2006, 2, 10, 0, 0, 0 }, "dd");
+
assertEqualDuration( "09 12", new int[] { 2006, 1, 20, 0, 0, 0 },
new int[] { 2006, 11, 4, 0, 0, 0 }, "MM dd");
assertEqualDuration( "287", new int[] { 2006, 1, 20, 0, 0, 0 },
- new int[] { 2006, 11, 4, 0, 0, 0 }, "dd");
+ new int[] { 2006, 11, 4, 0, 0, 0 }, "dd");
assertEqualDuration( "11 30", new int[] { 2006, 0, 2, 0, 0, 0 },
- new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd");
+ new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd");
assertEqualDuration( "364", new int[] { 2006, 0, 2, 0, 0, 0 },
- new int[] { 2007, 0, 1, 0, 0, 0 }, "dd");
+ new int[] { 2007, 0, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "12 00", new int[] { 2006, 0, 1, 0, 0, 0 },
- new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd");
+ new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd");
assertEqualDuration( "365", new int[] { 2006, 0, 1, 0, 0, 0 },
- new int[] { 2007, 0, 1, 0, 0, 0 }, "dd");
-
+ new int[] { 2007, 0, 1, 0, 0, 0 }, "dd");
+
assertEqualDuration( "31", new int[] { 2006, 0, 1, 0, 0, 0 },
- new int[] { 2006, 1, 1, 0, 0, 0 }, "dd");
-
+ new int[] { 2006, 1, 1, 0, 0, 0 }, "dd");
+
assertEqualDuration( "92", new int[] { 2005, 9, 1, 0, 0, 0 },
- new int[] { 2006, 0, 1, 0, 0, 0 }, "dd");
+ new int[] { 2006, 0, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "77", new int[] { 2005, 9, 16, 0, 0, 0 },
- new int[] { 2006, 0, 1, 0, 0, 0 }, "dd");
+ new int[] { 2006, 0, 1, 0, 0, 0 }, "dd");
// test month larger in start than end
assertEqualDuration( "136", new int[] { 2005, 9, 16, 0, 0, 0 },
- new int[] { 2006, 2, 1, 0, 0, 0 }, "dd");
+ new int[] { 2006, 2, 1, 0, 0, 0 }, "dd");
// test when start in leap year
assertEqualDuration( "136", new int[] { 2004, 9, 16, 0, 0, 0 },
- new int[] { 2005, 2, 1, 0, 0, 0 }, "dd");
+ new int[] { 2005, 2, 1, 0, 0, 0 }, "dd");
// test when end in leap year
assertEqualDuration( "137", new int[] { 2003, 9, 16, 0, 0, 0 },
- new int[] { 2004, 2, 1, 0, 0, 0 }, "dd");
+ new int[] { 2004, 2, 1, 0, 0, 0 }, "dd");
// test when end in leap year but less than end of feb
assertEqualDuration( "135", new int[] { 2003, 9, 16, 0, 0, 0 },
- new int[] { 2004, 1, 28, 0, 0, 0 }, "dd");
+ new int[] { 2004, 1, 28, 0, 0, 0 }, "dd");
assertEqualDuration( "364", new int[] { 2007, 0, 2, 0, 0, 0 },
- new int[] { 2008, 0, 1, 0, 0, 0 }, "dd");
+ new int[] { 2008, 0, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "729", new int[] { 2006, 0, 2, 0, 0, 0 },
- new int[] { 2008, 0, 1, 0, 0, 0 }, "dd");
+ new int[] { 2008, 0, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "365", new int[] { 2007, 2, 2, 0, 0, 0 },
- new int[] { 2008, 2, 1, 0, 0, 0 }, "dd");
+ new int[] { 2008, 2, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "333", new int[] { 2007, 1, 2, 0, 0, 0 },
- new int[] { 2008, 0, 1, 0, 0, 0 }, "dd");
+ new int[] { 2008, 0, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "28", new int[] { 2008, 1, 2, 0, 0, 0 },
- new int[] { 2008, 2, 1, 0, 0, 0 }, "dd");
+ new int[] { 2008, 2, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "393", new int[] { 2007, 1, 2, 0, 0, 0 },
- new int[] { 2008, 2, 1, 0, 0, 0 }, "dd");
+ new int[] { 2008, 2, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "369", new int[] { 2004, 0, 29, 0, 0, 0 },
- new int[] { 2005, 1, 1, 0, 0, 0 }, "dd");
+ new int[] { 2005, 1, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "338", new int[] { 2004, 1, 29, 0, 0, 0 },
- new int[] { 2005, 1, 1, 0, 0, 0 }, "dd");
+ new int[] { 2005, 1, 1, 0, 0, 0 }, "dd");
assertEqualDuration( "28", new int[] { 2004, 2, 8, 0, 0, 0 },
- new int[] { 2004, 3, 5, 0, 0, 0 }, "dd");
+ new int[] { 2004, 3, 5, 0, 0, 0 }, "dd");
assertEqualDuration( "48", new int[] { 1992, 1, 29, 0, 0, 0 },
- new int[] { 1996, 1, 29, 0, 0, 0 }, "M");
-
-
- // this seems odd - and will fail if I throw it in as a brute force
+ new int[] { 1996, 1, 29, 0, 0, 0 }, "M");
+
+
+ // this seems odd - and will fail if I throw it in as a brute force
// below as it expects the answer to be 12. It's a tricky edge case
assertEqualDuration( "11", new int[] { 1996, 1, 29, 0, 0, 0 },
- new int[] { 1997, 1, 28, 0, 0, 0 }, "M");
+ new int[] { 1997, 1, 28, 0, 0, 0 }, "M");
// again - this seems odd
assertEqualDuration( "11 28", new int[] { 1996, 1, 29, 0, 0, 0 },
- new int[] { 1997, 1, 28, 0, 0, 0 }, "M d");
-
+ new int[] { 1997, 1, 28, 0, 0, 0 }, "M d");
+
}
@Test
@@ -581,7 +581,7 @@ public class DurationFormatUtilsTest {
}
private static final int FOUR_YEARS = 365 * 3 + 366;
-
+
// Takes a minute to run, so generally turned off
// public void testBrutally() {
// Calendar c = Calendar.getInstance();
@@ -590,8 +590,8 @@ public class DurationFormatUtilsTest {
// bruteForce(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), "d", Calendar.DAY_OF_MONTH );
// c.add(Calendar.DAY_OF_MONTH, 1);
// }
-// }
-
+// }
+
private void bruteForce(final int year, final int month, final int day, final String format, final int calendarType) {
final String msg = year + "-" + month + "-" + day + " to ";
final Calendar c = Calendar.getInstance();
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
index 3de6df8..7197a98 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
@@ -162,10 +162,10 @@ public class FastDateFormatTest {
final FastDateFormat format = FastDateFormat.getInstance();
final FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT);
assertEquals(medium, format);
-
+
final SimpleDateFormat sdf = new SimpleDateFormat();
assertEquals(sdf.toPattern(), format.getPattern());
-
+
assertEquals(Locale.getDefault(), format.getLocale());
assertEquals(TimeZone.getDefault(), format.getTimeZone());
}
@@ -176,7 +176,7 @@ public class FastDateFormatTest {
final FastDateFormat shortLong = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.LONG, Locale.US);
final FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US);
final FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US);
-
+
assertFalse(shortShort.equals(shortLong));
assertFalse(shortShort.equals(longShort));
assertFalse(shortShort.equals(longLong));
@@ -187,13 +187,13 @@ public class FastDateFormatTest {
@Test
public void testDateDefaults() {
- assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, Locale.CANADA),
+ assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, Locale.CANADA),
FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getDefault(), Locale.CANADA));
-
- assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York")),
+
+ assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York")),
FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York"), Locale.getDefault()));
- assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG),
+ assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG),
FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getDefault(), Locale.getDefault()));
}
@@ -255,7 +255,7 @@ public class FastDateFormatTest {
final static private int NTHREADS= 10;
final static private int NROUNDS= 10000;
-
+
private AtomicLongArray measureTime(final Format printer, final Format parser) throws InterruptedException {
final ExecutorService pool = Executors.newFixedThreadPool(NTHREADS);
final AtomicInteger failures= new AtomicInteger(0);
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java
index 7857751..304332b 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java
@@ -36,7 +36,7 @@ import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
- * Compare FastDateParser with SimpleDateFormat
+ * Compare FastDateParser with SimpleDateFormat
*/
@RunWith(Parameterized.class)
public class FastDateParserSDFTest {
@@ -184,9 +184,9 @@ public class FastDateParserSDFTest {
fdfE = e.getClass();
}
if (valid) {
- assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime);
+ assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime);
} else {
- assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE);
+ assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE);
}
}
private void checkParsePosition(final String formattedDate) {
@@ -203,12 +203,12 @@ public class FastDateParserSDFTest {
final int length = formattedDate.length();
if (endIndex != length) {
// Error in test data
- throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length);
+ throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length);
}
} else {
final int errorIndex = sdfP.getErrorIndex();
if (errorIndex == -1) {
- throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime);
+ throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime);
}
}
@@ -225,6 +225,6 @@ public class FastDateParserSDFTest {
assertNotEquals("Test data error: expected FDF parse to fail, but got " + actualTime, -1, fdferrorIndex);
assertTrue("FDF error index ("+ fdferrorIndex + ") should approximate SDF index (" + sdferrorIndex + ")",
sdferrorIndex - fdferrorIndex <= 4);
- }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/1da8ccdb/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
index ed70757..c637f79 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
@@ -343,7 +343,7 @@ public class FastDateParserTest {
}
}
}
-
+
@Test
public void testJpLocales() {
@@ -421,7 +421,7 @@ public class FastDateParserTest {
testSdfAndFdp("''yyyyMMdd'A''B'HHmmssSSS''", "'20030210A'B153320989'", false); // OK
testSdfAndFdp("''''yyyyMMdd'A''B'HHmmssSSS''", "''20030210A'B153320989'", false); // OK
testSdfAndFdp("'$\\Ed'" ,"$\\Ed", false); // OK
-
+
// quoted charaters are case sensitive
testSdfAndFdp("'QED'", "QED", false);
testSdfAndFdp("'QED'", "qed", true);
@@ -429,7 +429,7 @@ public class FastDateParserTest {
testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 QED", false);
testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 qed", true);
}
-
+
@Test
public void testLANG_832() throws Exception {
testSdfAndFdp("'d'd" ,"d3", false); // OK
@@ -593,19 +593,19 @@ public class FastDateParserTest {
final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK);
assertEquals(REYKJAVIK, parser.getTimeZone());
}
-
+
@Test
public void testLang996() throws ParseException {
final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US);
expected.clear();
expected.set(2014, Calendar.MAY, 14);
- final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US);
+ final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US);
assertEquals(expected.getTime(), fdp.parse("14may2014"));
assertEquals(expected.getTime(), fdp.parse("14MAY2014"));
assertEquals(expected.getTime(), fdp.parse("14May2014"));
}
-
+
@Test(expected = IllegalArgumentException.class)
public void test1806Argument() {
getInstance("XXXX");
@@ -624,8 +624,8 @@ public class FastDateParserTest {
}
private static enum Expected1806 {
- India(INDIA, "+05", "+0530", "+05:30", true),
- Greenwich(GMT, "Z", "Z", "Z", false),
+ India(INDIA, "+05", "+0530", "+05:30", true),
+ Greenwich(GMT, "Z", "Z", "Z", false),
NewYork(NEW_YORK, "-05", "-0500", "-05:00", false);
private Expected1806(final TimeZone zone, final String one, final String two, final String three, final boolean hasHalfHourOffset) {
@@ -642,17 +642,17 @@ public class FastDateParserTest {
final String three;
final long offset;
}
-
+
@Test
public void test1806() throws ParseException {
final String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS";
final String dateStub = "2001-02-04T12:08:56.235";
-
+
for (final Expected1806 trial : Expected1806.values()) {
final Calendar cal = initializeCalendar(trial.zone);
final String message = trial.zone.getDisplayName()+";";
-
+
DateParser parser = getInstance(formatStub+"X", trial.zone);
assertEquals(message+trial.one, cal.getTime().getTime(), parser.parse(dateStub+trial.one).getTime()-trial.offset);