Exemplo n.º 1
0
 /**
  * Append a representation of the time zone of 'calendar' to 'buffer'.
  *
  * @param count the number of z or Z characters in the format string; "zzz" would be 3, for
  *     example.
  * @param generalTimeZone true if we should use a display name ("PDT") if available; false implies
  *     that we should use RFC 822 format ("-0800") instead. This corresponds to 'z' versus 'Z' in
  *     the format string.
  */
 private void appendTimeZone(StringBuffer buffer, int count, boolean generalTimeZone) {
   if (generalTimeZone) {
     TimeZone tz = calendar.getTimeZone();
     boolean daylight = (calendar.get(Calendar.DST_OFFSET) != 0);
     int style = count < 4 ? TimeZone.SHORT : TimeZone.LONG;
     if (!formatData.customZoneStrings) {
       buffer.append(tz.getDisplayName(daylight, style, formatData.locale));
       return;
     }
     // We can't call TimeZone.getDisplayName() because it would not use
     // the custom DateFormatSymbols of this SimpleDateFormat.
     String custom =
         TimeZoneNames.getDisplayName(formatData.zoneStrings, tz.getID(), daylight, style);
     if (custom != null) {
       buffer.append(custom);
       return;
     }
   }
   // We didn't find what we were looking for, so default to a numeric time zone.
   appendNumericTimeZone(buffer, count, generalTimeZone);
 }