You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/05/15 19:22:55 UTC
[commons-lang] branch master updated: [LANG-1680] FastDateFormat does not support the 'L'-Pattern from SimpleDateFormat.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new eff43864b [LANG-1680] FastDateFormat does not support the 'L'-Pattern from SimpleDateFormat.
eff43864b is described below
commit eff43864b34ab2be2eae4e9ac0e780d34fab57b3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 15 15:22:50 2022 -0400
[LANG-1680] FastDateFormat does not support the 'L'-Pattern from
SimpleDateFormat.
- Use final.
- Fix typos.
- In-line single use local variables.
---
src/changes/changes.xml | 1 +
.../org/apache/commons/lang3/time/DateUtils.java | 4 +-
.../apache/commons/lang3/time/DateUtilsTest.java | 58 +++++++++++-----------
.../commons/lang3/time/FastDateFormatTest.java | 4 +-
4 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c2f6ee637..e239b4f69 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -80,6 +80,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Make final mappingFunction variable #876.</action>
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Remove unnecessary variable creations #882.</action>
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Minor changes #769.</action>
+ <action issue="LANG-1680" type="fix" dev="ggregory" due-to="Michael Krause, Steve Bosman, Gary Gregory">FastDateFormat does not support the 'L'-Pattern from SimpleDateFormat.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add EnumUtils.getEnumSystemProperty(...).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TriConsumer.</action>
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index 493136e51..25a8275d8 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -1860,9 +1860,9 @@ public class DateUtils {
// Unfortunately standalone month names are not available in DateFormatSymbols,
// so we have to extract them.
final Calendar calendar = Calendar.getInstance(locale);
- Map<String, Integer> displayNames = calendar.getDisplayNames(Calendar.MONTH, style, locale);
+ final Map<String, Integer> displayNames = calendar.getDisplayNames(Calendar.MONTH, style, locale);
final String[] monthNames = new String[displayNames.size()];
- for (Map.Entry<String, Integer> entry: displayNames.entrySet()) {
+ for (final Map.Entry<String, Integer> entry: displayNames.entrySet()) {
monthNames[entry.getValue()] = entry.getKey();
}
return monthNames;
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 9e71e9873..7e9b40fad 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -1697,40 +1697,38 @@ public class DateUtilsTest {
@Test
public void testGetStandaloneLongMonthNames() {
- Locale testLocale = Locale.GERMAN;
- String[] standaloneShortMonths = DateUtils.getStandaloneLongMonths(testLocale);
- assertEquals(12, standaloneShortMonths.length);
- assertEquals("Januar", standaloneShortMonths[0]);
- assertEquals("Februar", standaloneShortMonths[1]);
- assertEquals("M\u00e4rz", standaloneShortMonths[2]);
- assertEquals("April", standaloneShortMonths[3]);
- assertEquals("Mai", standaloneShortMonths[4]);
- assertEquals("Juni", standaloneShortMonths[5]);
- assertEquals("Juli", standaloneShortMonths[6]);
- assertEquals("August", standaloneShortMonths[7]);
- assertEquals("September", standaloneShortMonths[8]);
- assertEquals("Oktober", standaloneShortMonths[9]);
- assertEquals("November", standaloneShortMonths[10]);
- assertEquals("Dezember", standaloneShortMonths[11]);
+ final String[] monthNames = DateUtils.getStandaloneLongMonths(Locale.GERMAN);
+ assertEquals(12, monthNames.length);
+ assertEquals("Januar", monthNames[0]);
+ assertEquals("Februar", monthNames[1]);
+ assertEquals("M\u00e4rz", monthNames[2]);
+ assertEquals("April", monthNames[3]);
+ assertEquals("Mai", monthNames[4]);
+ assertEquals("Juni", monthNames[5]);
+ assertEquals("Juli", monthNames[6]);
+ assertEquals("August", monthNames[7]);
+ assertEquals("September", monthNames[8]);
+ assertEquals("Oktober", monthNames[9]);
+ assertEquals("November", monthNames[10]);
+ assertEquals("Dezember", monthNames[11]);
}
@Test
public void testGetStandaloneShortMonthNames() {
- Locale testLocale = Locale.GERMAN;
- String[] standaloneShortMonths = DateUtils.getStandaloneShortMonths(testLocale);
- assertEquals(12, standaloneShortMonths.length);
- assertEquals("Jan", standaloneShortMonths[0]);
- assertEquals("Feb", standaloneShortMonths[1]);
- assertEquals("M\u00e4r", standaloneShortMonths[2]);
- assertEquals("Apr", standaloneShortMonths[3]);
- assertEquals("Mai", standaloneShortMonths[4]);
- assertEquals("Jun", standaloneShortMonths[5]);
- assertEquals("Jul", standaloneShortMonths[6]);
- assertEquals("Aug", standaloneShortMonths[7]);
- assertEquals("Sep", standaloneShortMonths[8]);
- assertEquals("Okt", standaloneShortMonths[9]);
- assertEquals("Nov", standaloneShortMonths[10]);
- assertEquals("Dez", standaloneShortMonths[11]);
+ final String[] monthNames = DateUtils.getStandaloneShortMonths(Locale.GERMAN);
+ assertEquals(12, monthNames.length);
+ assertEquals("Jan", monthNames[0]);
+ assertEquals("Feb", monthNames[1]);
+ assertEquals("M\u00e4r", monthNames[2]);
+ assertEquals("Apr", monthNames[3]);
+ assertEquals("Mai", monthNames[4]);
+ assertEquals("Jun", monthNames[5]);
+ assertEquals("Jul", monthNames[6]);
+ assertEquals("Aug", monthNames[7]);
+ assertEquals("Sep", monthNames[8]);
+ assertEquals("Okt", monthNames[9]);
+ assertEquals("Nov", monthNames[10]);
+ assertEquals("Dez", monthNames[11]);
}
}
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 725cd295f..68271ef25 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
@@ -329,7 +329,7 @@ public class FastDateFormatTest {
@Test
public void testStandaloneShortMonthForm() {
final TimeZone utc = FastTimeZone.getGmtTimeZone();
- Instant testInstant = LocalDate.of(1970, 9, 15).atStartOfDay(ZoneId.of("UTC")).toInstant();
+ final Instant testInstant = LocalDate.of(1970, 9, 15).atStartOfDay(ZoneId.of("UTC")).toInstant();
final Date date = Date.from(testInstant);
String dateAsString = FastDateFormat.getInstance("yyyy-LLL-dd", utc, Locale.GERMAN).format(date);
@@ -345,7 +345,7 @@ public class FastDateFormatTest {
@Test
public void testStandaloneLongMonthForm() {
final TimeZone utc = FastTimeZone.getGmtTimeZone();
- Instant testInstant = LocalDate.of(1970, 9, 15).atStartOfDay(ZoneId.of("UTC")).toInstant();
+ final Instant testInstant = LocalDate.of(1970, 9, 15).atStartOfDay(ZoneId.of("UTC")).toInstant();
final Date date = Date.from(testInstant);
String dateAsString = FastDateFormat.getInstance("yyyy-LLLL-dd", utc, Locale.GERMAN).format(date);