[LANG-1680] FastDateFormat does not support the 'L'-Pattern from
SimpleDateFormat. - Use final. - Fix typos. - In-line single use local variables.
This commit is contained in:
parent
127869e88f
commit
eff43864b3
|
@ -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">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">Remove unnecessary variable creations #882.</action>
|
||||||
<action type="fix" dev="ggregory" due-to="Arturo Bernal">Minor changes #769.</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 -->
|
<!-- ADD -->
|
||||||
<action type="add" dev="ggregory" due-to="Gary Gregory">Add EnumUtils.getEnumSystemProperty(...).</action>
|
<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>
|
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TriConsumer.</action>
|
||||||
|
|
|
@ -1860,9 +1860,9 @@ public class DateUtils {
|
||||||
// Unfortunately standalone month names are not available in DateFormatSymbols,
|
// Unfortunately standalone month names are not available in DateFormatSymbols,
|
||||||
// so we have to extract them.
|
// so we have to extract them.
|
||||||
final Calendar calendar = Calendar.getInstance(locale);
|
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()];
|
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();
|
monthNames[entry.getValue()] = entry.getKey();
|
||||||
}
|
}
|
||||||
return monthNames;
|
return monthNames;
|
||||||
|
|
|
@ -1697,40 +1697,38 @@ public class DateUtilsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStandaloneLongMonthNames() {
|
public void testGetStandaloneLongMonthNames() {
|
||||||
Locale testLocale = Locale.GERMAN;
|
final String[] monthNames = DateUtils.getStandaloneLongMonths(Locale.GERMAN);
|
||||||
String[] standaloneShortMonths = DateUtils.getStandaloneLongMonths(testLocale);
|
assertEquals(12, monthNames.length);
|
||||||
assertEquals(12, standaloneShortMonths.length);
|
assertEquals("Januar", monthNames[0]);
|
||||||
assertEquals("Januar", standaloneShortMonths[0]);
|
assertEquals("Februar", monthNames[1]);
|
||||||
assertEquals("Februar", standaloneShortMonths[1]);
|
assertEquals("M\u00e4rz", monthNames[2]);
|
||||||
assertEquals("M\u00e4rz", standaloneShortMonths[2]);
|
assertEquals("April", monthNames[3]);
|
||||||
assertEquals("April", standaloneShortMonths[3]);
|
assertEquals("Mai", monthNames[4]);
|
||||||
assertEquals("Mai", standaloneShortMonths[4]);
|
assertEquals("Juni", monthNames[5]);
|
||||||
assertEquals("Juni", standaloneShortMonths[5]);
|
assertEquals("Juli", monthNames[6]);
|
||||||
assertEquals("Juli", standaloneShortMonths[6]);
|
assertEquals("August", monthNames[7]);
|
||||||
assertEquals("August", standaloneShortMonths[7]);
|
assertEquals("September", monthNames[8]);
|
||||||
assertEquals("September", standaloneShortMonths[8]);
|
assertEquals("Oktober", monthNames[9]);
|
||||||
assertEquals("Oktober", standaloneShortMonths[9]);
|
assertEquals("November", monthNames[10]);
|
||||||
assertEquals("November", standaloneShortMonths[10]);
|
assertEquals("Dezember", monthNames[11]);
|
||||||
assertEquals("Dezember", standaloneShortMonths[11]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStandaloneShortMonthNames() {
|
public void testGetStandaloneShortMonthNames() {
|
||||||
Locale testLocale = Locale.GERMAN;
|
final String[] monthNames = DateUtils.getStandaloneShortMonths(Locale.GERMAN);
|
||||||
String[] standaloneShortMonths = DateUtils.getStandaloneShortMonths(testLocale);
|
assertEquals(12, monthNames.length);
|
||||||
assertEquals(12, standaloneShortMonths.length);
|
assertEquals("Jan", monthNames[0]);
|
||||||
assertEquals("Jan", standaloneShortMonths[0]);
|
assertEquals("Feb", monthNames[1]);
|
||||||
assertEquals("Feb", standaloneShortMonths[1]);
|
assertEquals("M\u00e4r", monthNames[2]);
|
||||||
assertEquals("M\u00e4r", standaloneShortMonths[2]);
|
assertEquals("Apr", monthNames[3]);
|
||||||
assertEquals("Apr", standaloneShortMonths[3]);
|
assertEquals("Mai", monthNames[4]);
|
||||||
assertEquals("Mai", standaloneShortMonths[4]);
|
assertEquals("Jun", monthNames[5]);
|
||||||
assertEquals("Jun", standaloneShortMonths[5]);
|
assertEquals("Jul", monthNames[6]);
|
||||||
assertEquals("Jul", standaloneShortMonths[6]);
|
assertEquals("Aug", monthNames[7]);
|
||||||
assertEquals("Aug", standaloneShortMonths[7]);
|
assertEquals("Sep", monthNames[8]);
|
||||||
assertEquals("Sep", standaloneShortMonths[8]);
|
assertEquals("Okt", monthNames[9]);
|
||||||
assertEquals("Okt", standaloneShortMonths[9]);
|
assertEquals("Nov", monthNames[10]);
|
||||||
assertEquals("Nov", standaloneShortMonths[10]);
|
assertEquals("Dez", monthNames[11]);
|
||||||
assertEquals("Dez", standaloneShortMonths[11]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ public class FastDateFormatTest {
|
||||||
@Test
|
@Test
|
||||||
public void testStandaloneShortMonthForm() {
|
public void testStandaloneShortMonthForm() {
|
||||||
final TimeZone utc = FastTimeZone.getGmtTimeZone();
|
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);
|
final Date date = Date.from(testInstant);
|
||||||
|
|
||||||
String dateAsString = FastDateFormat.getInstance("yyyy-LLL-dd", utc, Locale.GERMAN).format(date);
|
String dateAsString = FastDateFormat.getInstance("yyyy-LLL-dd", utc, Locale.GERMAN).format(date);
|
||||||
|
@ -345,7 +345,7 @@ public class FastDateFormatTest {
|
||||||
@Test
|
@Test
|
||||||
public void testStandaloneLongMonthForm() {
|
public void testStandaloneLongMonthForm() {
|
||||||
final TimeZone utc = FastTimeZone.getGmtTimeZone();
|
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);
|
final Date date = Date.from(testInstant);
|
||||||
|
|
||||||
String dateAsString = FastDateFormat.getInstance("yyyy-LLLL-dd", utc, Locale.GERMAN).format(date);
|
String dateAsString = FastDateFormat.getInstance("yyyy-LLLL-dd", utc, Locale.GERMAN).format(date);
|
||||||
|
|
Loading…
Reference in New Issue