ICU-9407 added @internals
X-SVN-Rev: 32014
This commit is contained in:
parent
4934b397a8
commit
203710a8f5
@ -94,7 +94,7 @@ import com.ibm.icu.util.ULocale.Category;
|
||||
* {@link #YEAR_ABBR_MONTH} for something like "Sept 2012". If you don't want to use one of the predefined skeletons,
|
||||
* you can supply your own. The skeletons are like the patterns in SimpleDateFormat, except they:
|
||||
* <ol>
|
||||
* <li>only keep the field pattern letter and all other parts in a pattern, such as space, punctuation, and
|
||||
* <li>only keep the field pattern letter and ignore all other parts in a pattern, such as space, punctuation, and
|
||||
* string literals.
|
||||
* <li>are independent of the order of fields.
|
||||
* <li>ignore certain differences in the field's pattern letter length:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2011, International Business Machines
|
||||
* Copyright (C) 2008-2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*/
|
||||
|
||||
@ -318,7 +318,7 @@ public class DateIntervalFormat extends UFormat {
|
||||
private DateIntervalFormat() {
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Construct a DateIntervalFormat from DateFormat,
|
||||
* a DateIntervalInfo, and skeleton.
|
||||
* DateFormat provides the timezone, calendar,
|
||||
@ -330,23 +330,26 @@ public class DateIntervalFormat extends UFormat {
|
||||
* @param locale the locale of this date interval formatter.
|
||||
* @param dtitvinf the DateIntervalInfo object to be adopted.
|
||||
* @param skeleton the skeleton of the date formatter
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
private DateIntervalFormat(ULocale locale, DateIntervalInfo dtItvInfo,
|
||||
String skeleton)
|
||||
public DateIntervalFormat(String skeleton, DateIntervalInfo dtItvInfo,
|
||||
DateTimePatternGenerator generator,
|
||||
SimpleDateFormat simpleDateFormat)
|
||||
{
|
||||
SimpleDateFormat dateFormat = simpleDateFormat;
|
||||
fDateFormat = dateFormat;
|
||||
// freeze date interval info
|
||||
dtItvInfo.freeze();
|
||||
fSkeleton = skeleton;
|
||||
fInfo = dtItvInfo;
|
||||
|
||||
DateTimePatternGenerator generator = DateTimePatternGenerator.getInstance(locale);
|
||||
final String bestPattern = generator.getBestPattern(skeleton);
|
||||
fDateFormat = new SimpleDateFormat(bestPattern, locale);
|
||||
fFromCalendar = (Calendar) fDateFormat.getCalendar().clone();
|
||||
fToCalendar = (Calendar) fDateFormat.getCalendar().clone();
|
||||
initializePattern();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton and the default <code>FORMAT</code> locale.
|
||||
@ -419,7 +422,8 @@ public class DateIntervalFormat extends UFormat {
|
||||
getInstance(String skeleton, ULocale locale)
|
||||
{
|
||||
DateIntervalInfo dtitvinf = new DateIntervalInfo(locale);
|
||||
return new DateIntervalFormat(locale, dtitvinf, skeleton);
|
||||
DateTimePatternGenerator generator = DateTimePatternGenerator.getInstance(locale);
|
||||
return new DateIntervalFormat(skeleton, dtitvinf, generator, new SimpleDateFormat(generator.getBestPattern(skeleton), locale));
|
||||
}
|
||||
|
||||
|
||||
@ -512,7 +516,8 @@ public class DateIntervalFormat extends UFormat {
|
||||
// clone. If it is frozen, clone returns itself, otherwise, clone
|
||||
// returns a copy.
|
||||
dtitvinf = (DateIntervalInfo)dtitvinf.clone();
|
||||
return new DateIntervalFormat(locale, dtitvinf, skeleton);
|
||||
DateTimePatternGenerator generator = DateTimePatternGenerator.getInstance(locale);
|
||||
return new DateIntervalFormat(skeleton, dtitvinf, generator, new SimpleDateFormat(generator.getBestPattern(skeleton), locale));
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +86,8 @@ import com.ibm.icu.util.UResourceBundle;
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public class DateTimePatternGenerator implements Freezable<DateTimePatternGenerator>, Cloneable {
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
// debugging flags
|
||||
//static boolean SHOW_DISTANCE = false;
|
||||
// TODO add hack to fix months for CJK, as per bug ticket 1099
|
||||
@ -286,6 +288,22 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
public char getDefaultHourFormatChar() {
|
||||
return defaultHourFormatChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
public void setDefaultHourFormatChar(char defaultHourFormatChar) {
|
||||
this.defaultHourFormatChar = defaultHourFormatChar;
|
||||
}
|
||||
|
||||
private static void hackTimes(DateTimePatternGenerator result, PatternInfo returnInfo, String hackPattern) {
|
||||
result.fp.set(hackPattern);
|
||||
StringBuilder mmss = new StringBuilder();
|
||||
@ -495,7 +513,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
return addPatternWithSkeleton(pattern, null, override, returnInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* addPatternWithSkeleton:
|
||||
* If skeletonToUse is specified, then an availableFormats entry is being added. In this case:
|
||||
* 1. We pass that skeleton to DateTimeMatcher().set instead of having it derive a skeleton from the pattern.
|
||||
@ -506,8 +524,10 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
* derived (i.e. entries derived from the standard date/time patters for the specified locale).
|
||||
* 3. When adding the pattern (skeleton2pattern.put, basePattern_pattern.put), we set a field to indicate that the added
|
||||
* entry had a specified skeleton.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
private DateTimePatternGenerator addPatternWithSkeleton(String pattern, String skeletonToUse, boolean override, PatternInfo returnInfo) {
|
||||
public DateTimePatternGenerator addPatternWithSkeleton(String pattern, String skeletonToUse, boolean override, PatternInfo returnInfo) {
|
||||
checkFrozen();
|
||||
DateTimeMatcher matcher;
|
||||
if (skeletonToUse == null) {
|
||||
@ -531,6 +551,9 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
returnInfo.status = PatternInfo.OK;
|
||||
returnInfo.conflictingPattern = "";
|
||||
PatternWithSkeletonFlag patWithSkelFlag = new PatternWithSkeletonFlag(pattern,skeletonToUse != null);
|
||||
if (DEBUG) {
|
||||
System.out.println(matcher + " => " + patWithSkelFlag);
|
||||
}
|
||||
skeleton2pattern.put(matcher, patWithSkelFlag);
|
||||
basePattern_pattern.put(basePattern, patWithSkelFlag);
|
||||
return this;
|
||||
@ -557,6 +580,7 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
* @param pattern Input pattern, such as "dd/MMM"
|
||||
* @return skeleton, such as "MMMdd"
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
public String getSkeletonAllowingDuplicates(String pattern) {
|
||||
synchronized (this) { // synchronized since a getter must be thread-safe
|
||||
@ -1537,6 +1561,9 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
|
||||
pattern = pat;
|
||||
skeletonWasSpecified = skelSpecified;
|
||||
}
|
||||
public String toString() {
|
||||
return pattern + "," + skeletonWasSpecified;
|
||||
}
|
||||
}
|
||||
private TreeMap<DateTimeMatcher, PatternWithSkeletonFlag> skeleton2pattern = new TreeMap<DateTimeMatcher, PatternWithSkeletonFlag>(); // items are in priority order
|
||||
private TreeMap<String, PatternWithSkeletonFlag> basePattern_pattern = new TreeMap<String, PatternWithSkeletonFlag>(); // items are in priority order
|
||||
|
Loading…
Reference in New Issue
Block a user