LANG-1092: Wrong formating of time zones with daylight saving time in FastDatePrinter
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1666568 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1f75a8f7cc
commit
8aa1b44ada
|
@ -22,6 +22,7 @@
|
|||
<body>
|
||||
|
||||
<release version="3.4" date="tba" description="tba">
|
||||
<action issue="LANG-1092" type="add" dev="britter">Wrong formating of time zones with daylight saving time in FastDatePrinter</action>
|
||||
<action issue="LANG-877" type="add" dev="britter" due-to="Fabian Lange">Performance improvements for StringEscapeUtils</action>
|
||||
<action issue="LANG-1093" type="add" dev="britter" due-to="Fabian Lange">Add ClassUtils.getAbbreviatedName()</action>
|
||||
<action issue="LANG-1090" type="fix" dev="sebb">FastDateParser does not set error indication in ParsePosition</action>
|
||||
|
|
|
@ -1162,8 +1162,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
@Override
|
||||
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
|
||||
final TimeZone zone = calendar.getTimeZone();
|
||||
if (zone.useDaylightTime()
|
||||
&& calendar.get(Calendar.DST_OFFSET) != 0) {
|
||||
if (calendar.get(Calendar.DST_OFFSET) != 0) {
|
||||
buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
|
||||
} else {
|
||||
buffer.append(getTimeZoneDisplay(zone, false, mStyle, mLocale));
|
||||
|
|
|
@ -265,23 +265,22 @@ public class FastDatePrinterTest {
|
|||
final String[] availableZones = TimeZone.getAvailableIDs();
|
||||
final TimeZone currentZone = TimeZone.getDefault();
|
||||
|
||||
TimeZone anotherZone = null;
|
||||
for (final String zone : availableZones) {
|
||||
if (!zone.equals(currentZone.getID())) {
|
||||
anotherZone = TimeZone.getTimeZone(zone);
|
||||
TimeZone anotherZone = TimeZone.getTimeZone(zone);
|
||||
|
||||
assertNotNull("Cannot find another timezone", anotherZone);
|
||||
|
||||
final String pattern = "h:mma z";
|
||||
final Calendar cal = Calendar.getInstance(anotherZone);
|
||||
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
sdf.setTimeZone(anotherZone);
|
||||
final String expectedValue = sdf.format(cal.getTime());
|
||||
final String actualValue = FastDateFormat.getInstance(pattern).format(cal);
|
||||
assertEquals(expectedValue, actualValue);
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull("Cannot find another timezone", anotherZone);
|
||||
|
||||
final String pattern = "h:mma z";
|
||||
final Calendar cal = Calendar.getInstance(anotherZone);
|
||||
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
sdf.setTimeZone(anotherZone);
|
||||
final String expectedValue = sdf.format(cal.getTime());
|
||||
final String actualValue = FastDateFormat.getInstance(pattern).format(cal);
|
||||
assertEquals(expectedValue, actualValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue