ICU 66.0.1  66.0.1
Public Member Functions | Static Public Member Functions
icu::DateTimePatternGenerator Class Reference

This class provides flexible generation of date format patterns, like "yy-MM-dd". More...

#include <dtptngen.h>

Inheritance diagram for icu::DateTimePatternGenerator:
icu::UObject icu::UMemory

Public Member Functions

virtual ~DateTimePatternGenerator ()
 Destructor. More...
 
DateTimePatternGeneratorclone () const
 Clone DateTimePatternGenerator object. More...
 
UBool operator== (const DateTimePatternGenerator &other) const
 Return true if another object is semantically equal to this one. More...
 
UBool operator!= (const DateTimePatternGenerator &other) const
 Return true if another object is semantically unequal to this one. More...
 
UnicodeString getSkeleton (const UnicodeString &pattern, UErrorCode &status)
 Utility to return a unique skeleton from a given pattern. More...
 
UnicodeString getBaseSkeleton (const UnicodeString &pattern, UErrorCode &status)
 Utility to return a unique base skeleton from a given pattern. More...
 
UDateTimePatternConflict addPattern (const UnicodeString &pattern, UBool override, UnicodeString &conflictingPattern, UErrorCode &status)
 Adds a pattern to the generator. More...
 
void setAppendItemFormat (UDateTimePatternField field, const UnicodeString &value)
 An AppendItem format is a pattern used to append a field if there is no good match. More...
 
const UnicodeStringgetAppendItemFormat (UDateTimePatternField field) const
 Getter corresponding to setAppendItemFormat. More...
 
void setAppendItemName (UDateTimePatternField field, const UnicodeString &value)
 Sets the names of field, eg "era" in English for ERA. More...
 
const UnicodeStringgetAppendItemName (UDateTimePatternField field) const
 Getter corresponding to setAppendItemNames. More...
 
UnicodeString getFieldDisplayName (UDateTimePatternField field, UDateTimePGDisplayWidth width) const
 The general interface to get a display name for a particular date/time field, in one of several possible display widths. More...
 
void setDateTimeFormat (const UnicodeString &dateTimeFormat)
 The DateTimeFormat is a message format pattern used to compose date and time patterns. More...
 
const UnicodeStringgetDateTimeFormat () const
 Getter corresponding to setDateTimeFormat. More...
 
UnicodeString getBestPattern (const UnicodeString &skeleton, UErrorCode &status)
 Return the best pattern matching the input skeleton. More...
 
UnicodeString getBestPattern (const UnicodeString &skeleton, UDateTimePatternMatchOptions options, UErrorCode &status)
 Return the best pattern matching the input skeleton. More...
 
UnicodeString replaceFieldTypes (const UnicodeString &pattern, const UnicodeString &skeleton, UErrorCode &status)
 Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton. More...
 
UnicodeString replaceFieldTypes (const UnicodeString &pattern, const UnicodeString &skeleton, UDateTimePatternMatchOptions options, UErrorCode &status)
 Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton. More...
 
StringEnumerationgetSkeletons (UErrorCode &status) const
 Return a list of all the skeletons (in canonical form) from this class. More...
 
const UnicodeStringgetPatternForSkeleton (const UnicodeString &skeleton) const
 Get the pattern corresponding to a given skeleton. More...
 
StringEnumerationgetBaseSkeletons (UErrorCode &status) const
 Return a list of all the base skeletons (in canonical form) from this class. More...
 
StringEnumerationgetRedundants (UErrorCode &status)
 Return a list of redundant patterns are those which if removed, make no difference in the resulting getBestPattern values. More...
 
void setDecimal (const UnicodeString &decimal)
 The decimal value is used in formatting fractions of seconds. More...
 
const UnicodeStringgetDecimal () const
 Getter corresponding to setDecimal. More...
 
virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class. More...
 
- Public Member Functions inherited from icu::UObject
virtual ~UObject ()
 Destructor. More...
 

Static Public Member Functions

static DateTimePatternGeneratorcreateInstance (UErrorCode &status)
 Construct a flexible generator according to default locale. More...
 
static DateTimePatternGeneratorcreateInstance (const Locale &uLocale, UErrorCode &status)
 Construct a flexible generator according to data for a given locale. More...
 
static DateTimePatternGeneratorinternalMakeInstance (const Locale &uLocale, UErrorCode &status)
 For ICU use only. More...
 
static DateTimePatternGeneratorcreateEmptyInstance (UErrorCode &status)
 Create an empty generator, to be constructed with addPattern(...) etc. More...
 
static UnicodeString staticGetSkeleton (const UnicodeString &pattern, UErrorCode &status)
 Utility to return a unique skeleton from a given pattern. More...
 
static UnicodeString staticGetBaseSkeleton (const UnicodeString &pattern, UErrorCode &status)
 Utility to return a unique base skeleton from a given pattern. More...
 
static UClassID getStaticClassID (void)
 ICU "poor man's RTTI", returns a UClassID for this class. More...
 

Detailed Description

This class provides flexible generation of date format patterns, like "yy-MM-dd".

The user can build up the generator by adding successive patterns. Once that is done, a query can be made using a "skeleton", which is a pattern which just includes the desired fields and lengths. The generator will return the "best fit" pattern corresponding to that skeleton.

The main method people will use is getBestPattern(String skeleton), since normally this class is pre-built with data from a particular locale. However, generators can be built directly from other data as well.

Issue: may be useful to also have a function that returns the list of fields in a pattern, in order, since we have that internally. That would be useful for getting the UI order of field elements.

Stable:
ICU 3.8

Definition at line 58 of file dtptngen.h.

Constructor & Destructor Documentation

◆ ~DateTimePatternGenerator()

virtual icu::DateTimePatternGenerator::~DateTimePatternGenerator ( )
virtual

Destructor.

Stable:
ICU 3.8

Member Function Documentation

◆ addPattern()

UDateTimePatternConflict icu::DateTimePatternGenerator::addPattern ( const UnicodeString pattern,
UBool  override,
UnicodeString conflictingPattern,
UErrorCode status 
)

Adds a pattern to the generator.

If the pattern has the same skeleton as an existing pattern, and the override parameter is set, then the previous value is overriden. Otherwise, the previous value is retained. In either case, the conflicting status is set and previous vale is stored in conflicting pattern.

Note that single-field patterns (like "MMM") are automatically added, and don't need to be added explicitly!

Parameters
patternInput pattern, such as "dd/MMM"
overrideWhen existing values are to be overridden use true, otherwise use false.
conflictingPatternPrevious pattern with the same skeleton.
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
conflicting status. The value could be UDATPG_NO_CONFLICT, UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
Stable:
ICU 3.8

Sample code

#include <iostream>
#include "unicode/ustdio.h"
UnicodeString conflictingPattern,dateReturned, pattern;
Locale locale=Locale::getFrance();
Calendar *cal = Calendar::createInstance(status);
cal->set (1999,9,13,23,58,59);
UDate date = cal->getTime(status);
// Create an DateTimePatternGenerator instance for the given locale
DateTimePatternGenerator *dtfg= DateTimePatternGenerator::createInstance(locale,status);
SimpleDateFormat *sdf = new SimpleDateFormat(dtfg->getBestPattern("MMMMddHmm",status),locale,status);
// Add '. von' to the existing pattern
dtfg->addPattern("dd'. von' MMMM", true, conflictingPattern,status);
// Apply the new pattern
sdf->applyPattern(dtfg->getBestPattern("MMMMddHmm",status));
dateReturned = sdf->format(date, dateReturned, status);
pattern =sdf->toPattern(pattern);
u_printf("%s\n", "New Pattern for FRENCH: ");
u_printf("%S\n", pattern.getTerminatedBuffer());
u_printf("%s\n", "Date Time in new Pattern: ");
u_printf("%S\n", dateReturned.getTerminatedBuffer());
delete dtfg;
delete sdf;
delete cal;

◆ clone()

DateTimePatternGenerator* icu::DateTimePatternGenerator::clone ( ) const

Clone DateTimePatternGenerator object.

Clients are responsible for deleting the DateTimePatternGenerator object cloned.

Stable:
ICU 3.8

◆ createEmptyInstance()

static DateTimePatternGenerator* icu::DateTimePatternGenerator::createEmptyInstance ( UErrorCode status)
static

Create an empty generator, to be constructed with addPattern(...) etc.

Parameters
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Stable:
ICU 3.8

◆ createInstance() [1/2]

static DateTimePatternGenerator* icu::DateTimePatternGenerator::createInstance ( UErrorCode status)
static

Construct a flexible generator according to default locale.

Parameters
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Stable:
ICU 3.8

◆ createInstance() [2/2]

static DateTimePatternGenerator* icu::DateTimePatternGenerator::createInstance ( const Locale uLocale,
UErrorCode status 
)
static

Construct a flexible generator according to data for a given locale.

Parameters
uLocale
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Stable:
ICU 3.8

◆ getAppendItemFormat()

const UnicodeString& icu::DateTimePatternGenerator::getAppendItemFormat ( UDateTimePatternField  field) const

Getter corresponding to setAppendItemFormat.

Values below 0 or at or above UDATPG_FIELD_COUNT are illegal arguments.

Parameters
fieldsuch as UDATPG_ERA_FIELD.
Returns
append pattern for field
Stable:
ICU 3.8

◆ getAppendItemName()

const UnicodeString& icu::DateTimePatternGenerator::getAppendItemName ( UDateTimePatternField  field) const

Getter corresponding to setAppendItemNames.

Values below 0 or at or above UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method for getting date/time field display names is getFieldDisplayName.

Parameters
fieldsuch as UDATPG_ERA_FIELD.
Returns
name for field
See also
getFieldDisplayName
Stable:
ICU 3.8

◆ getBaseSkeleton()

UnicodeString icu::DateTimePatternGenerator::getBaseSkeleton ( const UnicodeString pattern,
UErrorCode status 
)

Utility to return a unique base skeleton from a given pattern.

This is the same as the skeleton, except that differences in length are minimized so as to only preserve the difference between string and numeric form. So for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" (notice the single d). getBaseSkeleton() works exactly like staticGetBaseSkeleton(). Use staticGetBaseSkeleton() instead of getBaseSkeleton().

Parameters
patternInput pattern, such as "dd/MMM"
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
base skeleton, such as "MMMd"
Stable:
ICU 3.8

◆ getBaseSkeletons()

StringEnumeration* icu::DateTimePatternGenerator::getBaseSkeletons ( UErrorCode status) const

Return a list of all the base skeletons (in canonical form) from this class.

Parameters
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
a StringEnumeration with the base skeletons. The caller must delete the object.
Stable:
ICU 3.8

◆ getBestPattern() [1/2]

UnicodeString icu::DateTimePatternGenerator::getBestPattern ( const UnicodeString skeleton,
UErrorCode status 
)

Return the best pattern matching the input skeleton.

It is guaranteed to have all of the fields in the skeleton.

Parameters
skeletonThe skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
bestPattern The best pattern found from the given skeleton.
Stable:
ICU 3.8

Sample code

#include <iostream>
#include "unicode/ustdio.h"
UnicodeString skeletons [] = {
UnicodeString("yQQQQ"), // year + full name of quarter, i.e., 4th quarter 1999
UnicodeString("yMMMM"), // year + full name of month, i.e., October 1999
UnicodeString("MMMMd"), // full name of month + day of the month, i.e., October 25
UnicodeString("hhmm"), // 12-hour-cycle format, i.e., 1:32 PM
UnicodeString("jjmm"), // preferred hour format for the given locale, i.e., 24-hour-cycle format for fr_FR
0,
};
Locale locales[] = {
Locale ("en_US"),
Locale ("fr_FR"),
Locale ("zh_CN"),
};
const char* filename = "sample.txt";
/* open a UTF-8 file for writing */
UFILE* f = u_fopen(filename, "w", NULL,"UTF-8");
UnicodeString dateReturned;
Calendar *cal = Calendar::createInstance(status);
cal->set (1999,9,13,23,58,59);
UDate date = cal->getTime(status);
u_fprintf(f, "%-20S%-20S%-20S%-20S\n", UnicodeString("Skeleton").getTerminatedBuffer(),UnicodeString("en_US").getTerminatedBuffer(),UnicodeString("fr_FR").getTerminatedBuffer(),UnicodeString("zh_CN").getTerminatedBuffer());
for (int i=0;skeletons[i]!=NULL;i++) {
u_fprintf(f, "%-20S",skeletons[i].getTerminatedBuffer());
for (int j=0;j<sizeof(locales)/sizeof(locales[0]);j++) {
// create a DateTimePatternGenerator instance for given locale
DateTimePatternGenerator *dtfg= DateTimePatternGenerator::createInstance(locales[j],status);
// use getBestPattern method to get the best pattern for the given skeleton
UnicodeString pattern = dtfg->getBestPattern(skeletons[i],status);
// Constructs a SimpleDateFormat with the best pattern generated above and the given locale
SimpleDateFormat *sdf = new SimpleDateFormat(pattern,locales[j],status);
dateReturned.remove();
// Get the format of the given date
sdf->format(date,dateReturned,status);
/* write Unicode string to file */
u_fprintf(f, "%-20S", dateReturned.getTerminatedBuffer());
delete dtfg;
delete sdf;
}
u_fprintf(f,"\n");
}
/* close the file resource */
delete cal;

◆ getBestPattern() [2/2]

UnicodeString icu::DateTimePatternGenerator::getBestPattern ( const UnicodeString skeleton,
UDateTimePatternMatchOptions  options,
UErrorCode status 
)

Return the best pattern matching the input skeleton.

It is guaranteed to have all of the fields in the skeleton.

Parameters
skeletonThe skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
optionsOptions for forcing the length of specified fields in the returned pattern to match those in the skeleton (when this would not happen otherwise). For default behavior, use UDATPG_MATCH_NO_OPTIONS.
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
bestPattern The best pattern found from the given skeleton.
Stable:
ICU 4.4

◆ getDateTimeFormat()

const UnicodeString& icu::DateTimePatternGenerator::getDateTimeFormat ( ) const

Getter corresponding to setDateTimeFormat.

Returns
DateTimeFormat.
Stable:
ICU 3.8

◆ getDecimal()

const UnicodeString& icu::DateTimePatternGenerator::getDecimal ( ) const

Getter corresponding to setDecimal.

Returns
UnicodeString corresponding to the decimal point
Stable:
ICU 3.8

◆ getDynamicClassID()

virtual UClassID icu::DateTimePatternGenerator::getDynamicClassID ( ) const
virtual

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 3.8

Reimplemented from icu::UObject.

◆ getFieldDisplayName()

UnicodeString icu::DateTimePatternGenerator::getFieldDisplayName ( UDateTimePatternField  field,
UDateTimePGDisplayWidth  width 
) const

The general interface to get a display name for a particular date/time field, in one of several possible display widths.

Parameters
fieldThe desired UDateTimePatternField, such as UDATPG_ERA_FIELD.
widthThe desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED.
Returns
The display name for field
Stable:
ICU 61

◆ getPatternForSkeleton()

const UnicodeString& icu::DateTimePatternGenerator::getPatternForSkeleton ( const UnicodeString skeleton) const

Get the pattern corresponding to a given skeleton.

Parameters
skeleton
Returns
pattern corresponding to a given skeleton.
Stable:
ICU 3.8

◆ getRedundants()

StringEnumeration* icu::DateTimePatternGenerator::getRedundants ( UErrorCode status)

Return a list of redundant patterns are those which if removed, make no difference in the resulting getBestPattern values.

This method returns a list of them, to help check the consistency of the patterns used to build this generator.

Parameters
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
a StringEnumeration with the redundant pattern. The caller must delete the object.
Internal:
Do not use. This API is for internal use only. ICU 3.8

◆ getSkeleton()

UnicodeString icu::DateTimePatternGenerator::getSkeleton ( const UnicodeString pattern,
UErrorCode status 
)

Utility to return a unique skeleton from a given pattern.

For example, both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". getSkeleton() works exactly like staticGetSkeleton(). Use staticGetSkeleton() instead of getSkeleton().

Parameters
patternInput pattern, such as "dd/MMM"
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
skeleton such as "MMMdd"
Stable:
ICU 3.8

◆ getSkeletons()

StringEnumeration* icu::DateTimePatternGenerator::getSkeletons ( UErrorCode status) const

Return a list of all the skeletons (in canonical form) from this class.

Call getPatternForSkeleton() to get the corresponding pattern.

Parameters
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
StringEnumeration with the skeletons. The caller must delete the object.
Stable:
ICU 3.8

◆ getStaticClassID()

static UClassID icu::DateTimePatternGenerator::getStaticClassID ( void  )
static

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 3.8

◆ internalMakeInstance()

static DateTimePatternGenerator* icu::DateTimePatternGenerator::internalMakeInstance ( const Locale uLocale,
UErrorCode status 
)
static

For ICU use only.

Internal:
Do not use. This API is for internal use only.

◆ operator!=()

UBool icu::DateTimePatternGenerator::operator!= ( const DateTimePatternGenerator other) const

Return true if another object is semantically unequal to this one.

Parameters
otherthe DateTimePatternGenerator object to be compared with.
Returns
true if other is semantically unequal to this.
Stable:
ICU 3.8

◆ operator==()

UBool icu::DateTimePatternGenerator::operator== ( const DateTimePatternGenerator other) const

Return true if another object is semantically equal to this one.

Parameters
otherthe DateTimePatternGenerator object to be compared with.
Returns
true if other is semantically equal to this.
Stable:
ICU 3.8

◆ replaceFieldTypes() [1/2]

UnicodeString icu::DateTimePatternGenerator::replaceFieldTypes ( const UnicodeString pattern,
const UnicodeString skeleton,
UErrorCode status 
)

Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton.

That is, if you supply a pattern like "d-M H:m", and a skeleton of "MMMMddhhmm", then the input pattern is adjusted to be "dd-MMMM hh:mm". This is used internally to get the best match for the input skeleton, but can also be used externally.

Parameters
patternInput pattern
skeletonThe skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
pattern adjusted to match the skeleton fields widths and subtypes.
Stable:
ICU 3.8

Sample code

#include <iostream>
#include "unicode/ustdio.h"
UFILE *out = u_finit(stdout, NULL, "UTF-8");
UnicodeString pattern,dateReturned;
Locale locale =Locale::getFrance();
Calendar *cal = Calendar::createInstance(status);
cal->set (1999,9,13,23,58,59);
UDate date = cal->getTime(status);
TimeZone *zone = TimeZone::createTimeZone(UnicodeString("Europe/Paris"));
DateTimePatternGenerator *dtfg = DateTimePatternGenerator::createInstance(locale,status);
SimpleDateFormat *sdf = new SimpleDateFormat("EEEE d MMMM y HH:mm:ss zzzz",locale,status);
sdf->setTimeZone(*zone);
pattern = sdf->toPattern(pattern);
u_fprintf(out, "%S\n", UnicodeString("Pattern before replacement:").getTerminatedBuffer());
u_fprintf(out, "%S\n", pattern.getTerminatedBuffer());
dateReturned.remove();
dateReturned = sdf->format(date, dateReturned, status);
u_fprintf(out, "%S\n", UnicodeString("Date/Time format in fr_FR:").getTerminatedBuffer());
u_fprintf(out, "%S\n", dateReturned.getTerminatedBuffer());
// Replace zone "zzzz" in the pattern with "vvvv"
UnicodeString newPattern = dtfg->replaceFieldTypes(pattern, "vvvv", status);
// Apply the new pattern
sdf->applyPattern(newPattern);
dateReturned.remove();
dateReturned = sdf->format(date, dateReturned, status);
u_fprintf(out, "%S\n", UnicodeString("Pattern after replacement:").getTerminatedBuffer());
u_fprintf(out, "%S\n", newPattern.getTerminatedBuffer());
u_fprintf(out, "%S\n", UnicodeString("Date/Time format in fr_FR:").getTerminatedBuffer());
u_fprintf(out, "%S\n", dateReturned.getTerminatedBuffer());
delete sdf;
delete dtfg;
delete zone;
delete cal;
u_fclose(out);

◆ replaceFieldTypes() [2/2]

UnicodeString icu::DateTimePatternGenerator::replaceFieldTypes ( const UnicodeString pattern,
const UnicodeString skeleton,
UDateTimePatternMatchOptions  options,
UErrorCode status 
)

Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton.

That is, if you supply a pattern like "d-M H:m", and a skeleton of "MMMMddhhmm", then the input pattern is adjusted to be "dd-MMMM hh:mm". This is used internally to get the best match for the input skeleton, but can also be used externally.

Parameters
patternInput pattern
skeletonThe skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
optionsOptions controlling whether the length of specified fields in the pattern are adjusted to match those in the skeleton (when this would not happen otherwise). For default behavior, use UDATPG_MATCH_NO_OPTIONS.
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
pattern adjusted to match the skeleton fields widths and subtypes.
Stable:
ICU 4.4

◆ setAppendItemFormat()

void icu::DateTimePatternGenerator::setAppendItemFormat ( UDateTimePatternField  field,
const UnicodeString value 
)

An AppendItem format is a pattern used to append a field if there is no good match.

For example, suppose that the input skeleton is "GyyyyMMMd", and there is no matching pattern internally, but there is a pattern matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the G. The way these two are conjoined is by using the AppendItemFormat for G (era). So if that value is, say "{0}, {1}" then the final resulting pattern is "d-MM-yyyy, G".

There are actually three available variables: {0} is the pattern so far, {1} is the element we are adding, and {2} is the name of the element.

This reflects the way that the CLDR data is organized.

Parameters
fieldsuch as UDATPG_ERA_FIELD.
valuepattern, such as "{0}, {1}"
Stable:
ICU 3.8

◆ setAppendItemName()

void icu::DateTimePatternGenerator::setAppendItemName ( UDateTimePatternField  field,
const UnicodeString value 
)

Sets the names of field, eg "era" in English for ERA.

These are only used if the corresponding AppendItemFormat is used, and if it contains a {2} variable.

This reflects the way that the CLDR data is organized.

Parameters
fieldsuch as UDATPG_ERA_FIELD.
valuename of the field
Stable:
ICU 3.8

◆ setDateTimeFormat()

void icu::DateTimePatternGenerator::setDateTimeFormat ( const UnicodeString dateTimeFormat)

The DateTimeFormat is a message format pattern used to compose date and time patterns.

The default pattern in the root locale is "{1} {0}", where {1} will be replaced by the date pattern and {0} will be replaced by the time pattern; however, other locales may specify patterns such as "{1}, {0}" or "{1} 'at' {0}", etc.

This is used when the input skeleton contains both date and time fields, but there is not a close match among the added patterns. For example, suppose that this object was created by adding "dd-MMM" and "hh:mm", and its datetimeFormat is the default "{1} {0}". Then if the input skeleton is "MMMdhmm", there is not an exact match, so the input skeleton is broken up into two components "MMMd" and "hmm". There are close matches for those two skeletons, so the result is put together with this pattern, resulting in "d-MMM h:mm".

Parameters
dateTimeFormatmessage format pattern, here {1} will be replaced by the date pattern and {0} will be replaced by the time pattern.
Stable:
ICU 3.8

◆ setDecimal()

void icu::DateTimePatternGenerator::setDecimal ( const UnicodeString decimal)

The decimal value is used in formatting fractions of seconds.

If the skeleton contains fractional seconds, then this is used with the fractional seconds. For example, suppose that the input pattern is "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and the decimal string is ",". Then the resulting pattern is modified to be "H:mm:ss,SSSS"

Parameters
decimal
Stable:
ICU 3.8

◆ staticGetBaseSkeleton()

static UnicodeString icu::DateTimePatternGenerator::staticGetBaseSkeleton ( const UnicodeString pattern,
UErrorCode status 
)
static

Utility to return a unique base skeleton from a given pattern.

This is the same as the skeleton, except that differences in length are minimized so as to only preserve the difference between string and numeric form. So for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" (notice the single d).

Parameters
patternInput pattern, such as "dd/MMM"
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
base skeleton, such as "MMMd"
Stable:
ICU 56

◆ staticGetSkeleton()

static UnicodeString icu::DateTimePatternGenerator::staticGetSkeleton ( const UnicodeString pattern,
UErrorCode status 
)
static

Utility to return a unique skeleton from a given pattern.

For example, both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".

Parameters
patternInput pattern, such as "dd/MMM"
statusOutput param set to success/failure code on exit, which must not indicate a failure before the function call.
Returns
skeleton such as "MMMdd"
Stable:
ICU 56

The documentation for this class was generated from the following file: