mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 04:29:31 +00:00
ICU-6644 The fix for ticket#6644. Also changed _getDisplayName to synchronized method to prevent threading problem.
X-SVN-Rev: 25019
This commit is contained in:
parent
6da502fba9
commit
23d651a590
1 changed files with 3 additions and 6 deletions
|
@ -391,10 +391,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
|||
/**
|
||||
* The public version of this API only accepts LONG/SHORT, the
|
||||
* internal version (which this calls) also accepts LONG_GENERIC/SHORT_GENERIC.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
private String _getDisplayName(boolean daylight, int style, ULocale locale) {
|
||||
private synchronized String _getDisplayName(boolean daylight, int style, ULocale locale) {
|
||||
if (locale == null) {
|
||||
throw new NullPointerException("locale is null");
|
||||
}
|
||||
|
@ -404,7 +402,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
|||
* more efficiently but it would duplicate the SimpleDateFormat code
|
||||
* here, which is undesirable.
|
||||
* (2) Attempts to move the code from SimpleDateFormat to here also run
|
||||
* aground because this requires SimpleDateFormat to keep a Locale
|
||||
* around because this requires SimpleDateFormat to keep a Locale
|
||||
* object around, which it currently doesn't; to synthesize such a
|
||||
* locale upon resurrection; and to somehow handle the special case of
|
||||
* construction from a DateFormatSymbols object.
|
||||
|
@ -420,17 +418,16 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
|||
|
||||
String[] patterns = { "z", "zzzz", "v", "vvvv" };
|
||||
format.applyPattern(patterns[style]);
|
||||
format.setTimeZone(this);
|
||||
Date d = new Date();
|
||||
if (style >= 2) {
|
||||
// Generic names may change time to time even for a single time zone.
|
||||
// This method returns the one used for the zone now.
|
||||
format.setTimeZone(this);
|
||||
return format.format(d);
|
||||
} else {
|
||||
int[] offsets = new int[2];
|
||||
getOffset(d.getTime(), false, offsets);
|
||||
if ((daylight && offsets[1] != 0) || (!daylight && offsets[1] == 0)) {
|
||||
format.setTimeZone(this);
|
||||
return format.format(d);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue