@@ -432,14 +432,7 @@ public StringBuffer format(Date date, StringBuffer toAppendTo,
432
432
protected void _format (TimeZone tz , Locale loc , Date date ,
433
433
StringBuffer buffer )
434
434
{
435
- Calendar cal = _calendar ;
436
- if (cal == null ) {
437
- _calendar = cal = (Calendar )CALENDAR .clone ();
438
- }
439
- if (!cal .getTimeZone ().equals (tz ) ) {
440
- cal .setTimeZone (tz );
441
- }
442
- // Note: Calendar locale not updated since we don't need it here...
435
+ Calendar cal = _getCalendar (tz );
443
436
cal .setTime (date );
444
437
445
438
pad4 (buffer , cal .get (Calendar .YEAR ));
@@ -605,10 +598,7 @@ protected Date _parseAsISO8601(String dateStr, ParsePosition bogus)
605
598
if ((_timezone != null ) && ('Z' != dateStr .charAt (totalLen -1 ))) {
606
599
tz = _timezone ;
607
600
}
608
- Calendar cal = new GregorianCalendar (tz , _locale );
609
- if (_lenient != null ) {
610
- cal .setLenient (_lenient .booleanValue ());
611
- }
601
+ Calendar cal = _getCalendar (tz );
612
602
String formatStr ;
613
603
if (totalLen <= 10 ) {
614
604
Matcher m = PATTERN_PLAIN .matcher (dateStr );
@@ -757,6 +747,20 @@ protected void _clearFormats() {
757
747
_formatRFC1123 = null ;
758
748
}
759
749
750
+ protected Calendar _getCalendar (TimeZone tz ) {
751
+ Calendar cal = _calendar ;
752
+ if (cal == null ) {
753
+ _calendar = cal = (Calendar )CALENDAR .clone ();
754
+ }
755
+ if (!cal .getTimeZone ().equals (tz ) ) {
756
+ cal .setTimeZone (tz );
757
+ }
758
+ cal .setLenient (isLenient ());
759
+ cal .clear ();
760
+
761
+ return cal ;
762
+ }
763
+
760
764
protected static <T > boolean _equals (T value1 , T value2 ) {
761
765
if (value1 == value2 ) {
762
766
return true ;
0 commit comments