public class DateConversionDelegateFactory extends java.lang.Object implements EDataType.Internal.ConversionDelegate.Factory
conversion delegate factory
for converting long
, Long
Date
, java.sql.Date
, Calendar
, GregorianCalendar
, and XMLGregorianCalendar
instances to and from a string representation.
The annotation detail for the "format"
key of this annotation must be present and the value must be one of the following forms:
//Long
//SimpleDateFormat/<simple-date-format-pattern>/<language>/<country>/<variant>
//DateFormat/<date-style>/<language>/<country>/<variant>
//DateTimeFormat/<date-style>/<time-style>/<language>/<country>/<variant>
//TimeFormat/<time-style>/<language>/<country>/<variant>
The each of the value above have the following corresponding meaning:
Long
.
SimpleDateFormat
with the specified pattern.
The locale
specified by language
, country
, and variant
will be used to construct the SimpleDataFormat.
All the locale segments are optional, but should be specified if the date format is locale-specific to ensure that the serialization is portable to any other locale.
DateFormat.getDateInstance(int, Locale)
.
The date-style
must be one of FULL
, LONG
, MEDIUM
, or SHORT
.
The locale
specified by language
, country
, and variant
will be used to specify the DateFormat.
The variant is optional, but the language
and country
must be specified to ensure that the serialization is portable to any other locale.
DateFormat.getDateTimeInstance(int, int, Locale)
.
The date-style
must be one of FULL
, LONG
, MEDIUM
, or SHORT
.
The time-style
must be one of FULL
, LONG
, MEDIUM
, or SHORT
.
The locale
specified by language
, country
, and variant
will be used to specify the DateFormat.
The variant is optional, but the language
and country
must be specified to ensure that the serialization is portable to any other locale.
DateFormat.getTimeInstance(int, Locale)
.
The time-style
must be one of FULL
, LONG
, MEDIUM
, or SHORT
.
The locale
specified by language
, country
, and variant
will be used to specify the DateFormat.
The variant is optional, but the language
and country
must be specified to ensure that the serialization is portable to any other locale.
In all cases, the language
, country
, and variant
, when present, must specify an available
locale.
In the case that the data type is a Calendar
, other than GregorianCalendar
,
the URI may include a query segment specifying the calendar type
, e.g.,
When absent,//...?gregory
//...?japanese
//...?buddhist
gregory
is the default.
To ensure that a serialized value is portable across all time zones
,
for those formats based on a date format, i.e., all them except //Long
,
the associated format's time zone is set
to GMT .
Modifier and Type | Class and Description |
---|---|
static class |
DateConversionDelegateFactory.AnnotationValidator
An annotation validator for validating
http:///org/eclipse/emf/ecore/util/DateConversionDelegate annotations. |
static class |
DateConversionDelegateFactory.CalendarBuilder
A class that encapsulates the creation of a calendar from the instant in time or a
Date . |
EDataType.Internal.ConversionDelegate.Factory.Descriptor, EDataType.Internal.ConversionDelegate.Factory.Registry
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANNOTATION_URI
The annotation URI of thing conversion delegate factory.
|
static java.util.Set<java.lang.String> |
CALENDAR_TYPES |
Constructor and Description |
---|
DateConversionDelegateFactory() |
Modifier and Type | Method and Description |
---|---|
EDataType.Internal.ConversionDelegate |
createConversionDelegate(EDataType eDataType)
Creates a conversion delegate for the given EDataType.
|
static DateConversionDelegateFactory.CalendarBuilder |
getCalendarBuilder(java.lang.String calendarType)
Returns the calendar builder for the given
calendar type . |
static java.text.DateFormat |
getDateFormat(URI formatURI)
Returns the date format specified by the format URI.
|
public static final java.lang.String ANNOTATION_URI
public static java.util.Set<java.lang.String> CALENDAR_TYPES
public static DateConversionDelegateFactory.CalendarBuilder getCalendarBuilder(java.lang.String calendarType)
calendar type
.
The type gregory
is always present.calendarType
- the calendar type.public EDataType.Internal.ConversionDelegate createConversionDelegate(EDataType eDataType)
This implementation uses the "format"
detail value to create a conversion delegate.
createConversionDelegate
in interface EDataType.Internal.ConversionDelegate.Factory
eDataType
- the EDataType for which a conversion delegate is to be created.public static java.text.DateFormat getDateFormat(URI formatURI) throws java.lang.IllegalArgumentException
formatURI
- the format URI as described in DateConversionDelegate
.java.lang.IllegalArgumentException
- if the format is ill-formed.Copyright © 2022. Licensed under the Eclipse Public License v2.0. All rights reserved.
Submit a bug or feature