Package com.adobe.xfa.ut
Class LcTime
java.lang.Object
com.adobe.xfa.ut.LcTime
- Direct Known Subclasses:
ISOTime
The LcTime class defines objects in support
of XFA time picture patterns.
The time is internally represented as the number of milliseconds from the epoch, which is midnight 00:00:00 GMT, i.e., time 1 is midnight GMT.
Time picture patterns are used to parse and format time strings. Here are the metasymbols that form valid time picture patterns:
- h
- a one or two digit (1-12) hour of AM/PM.
- hh
- a two digit (01-12) hour of AM/PM.
- k
- a one or two digit (0-11) hour of AM/PM.
- kk
- a two digit (00-11) hour of AM/PM.
- H
- a one or two digit (0-23) hour of day.
- HH
- a two digit (00-23) hour of day.
- K
- a one or two digit (1-24) hour of day.
- KK
- a two digit (01-24) hour of day.
- M
- a one or two digit (0-59) minute of hour.
- MM
- a two digit (00-59) minute of hour.
- S
- a one or two digit (0-59) second of minute.
- SS
- a two digit (00-59) second of minute.
- FFF
- a three digit (000-999) thousandth of second.
- A
- a meridiem name (AM/PM) of the ambient locale.
- Z
- an abbreviated time zone name of the ambient locale.
- z
- an ISO8601 time zone format: Z, +HH[MM], -HH[MM].
- zz
- an alternate ISO8601 time zone format: Z, +HH[:MM], -HH[:MM].
LcTime to reformat a
time string
import com.adobe.xfa.ut.LcTime; // for defn of LcTime.
...
String loc = "en_ca"
String fmt = LcTime.DEFAULT_TIME_FMT;
LcTime now = new LcTime(loc);
now.setLocalTime();
now += 2 * LcTime.MILLISPERHOUR;
if (now.isValid())
System.out.println(now.format("h:MM:SS:FFF A Z"));
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault LcTime pattern string for English_US locale: h:MM:SS A.static final intstatic final intstatic final intstatic final intstatic final StringISO8601/XFA time pattern string: HHMMSS.FFFz.static final StringAlternate ISO8601/XFA time pattern string: HH:MM:SS.FFFzz.static final StringLcTime pattern symbols: hkHKMSFAzZ. -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates an LcTime object from the number of milliseconds from the epoch and in the locale given.Instantiates an LcTime object from an existing LcTime objectInstantiates an LcTime object from today's Greenwich Mean time and in the locale given.Instantiates an LcTime object from the given time in the pattern given and in the locale given. -
Method Summary
Modifier and TypeMethodDescriptionadd(int millis) Adds the given milliseconds to this object.Assigns the given LcTime object to this object.Formats this object given a time pattern string.intgetDays()Gets this lcTime object's difference in days from Greenwich Mean.intgetHour()Gets the hour of the day.static StringgetLocalTimeFormat(int style, String locale) Gets the localized time pattern in the given style for the given locale.intGets the number of milliseconds since the epoch.intGets the fraction of the second.intGets the minute of the hour.intGets the second of the hour.static StringgetTimeFormat(int style, String locale) Gets the time pattern in the given style for the given locale.intGet timezone in minutes west of GreenwichbooleanisValid()Determines if this object is valid.voidSets this object to operate on Greenwich Mean time, which is the default.voidSets this object to operate on local time as opposed to the default, which is Greenwich Mean time.toString()Formats this object according to the default pattern.
-
Field Details
-
DEFAULT_TIME_FMT
Default LcTime pattern string for English_US locale: h:MM:SS A.- See Also:
-
MILLISPERDAY
public static final int MILLISPERDAY- See Also:
-
MILLISPERHOUR
public static final int MILLISPERHOUR- See Also:
-
MILLISPERMINUTE
public static final int MILLISPERMINUTE- See Also:
-
MILLISPERSECOND
public static final int MILLISPERSECOND- See Also:
-
TIME_FMT1
ISO8601/XFA time pattern string: HHMMSS.FFFz.- See Also:
-
TIME_FMT2
Alternate ISO8601/XFA time pattern string: HH:MM:SS.FFFzz.- See Also:
-
TIME_PICTURE_SYMBOLS
LcTime pattern symbols: hkHKMSFAzZ.- See Also:
-
-
Constructor Details
-
LcTime
Instantiates an LcTime object from today's Greenwich Mean time and in the locale given.- Parameters:
locale- a locale string. When empty, it will default to the default locale.
-
LcTime
Instantiates an LcTime object from the number of milliseconds from the epoch and in the locale given. The epoch is such that time 1 corresponds to midnight, 00:00:00 GMT.- Parameters:
millis- the number of milliseconds from epoch.locale- a locale string. When empty, it will default to the default locale.
-
LcTime
Instantiates an LcTime object from the given time in the pattern given and in the locale given.- Parameters:
time- a time string.pat- a time pattern string used to parse the given time.locale- a locale string. When empty, it will default to the default locale.
-
LcTime
Instantiates an LcTime object from an existing LcTime object- Parameters:
oTime- an existing LcTime object
-
-
Method Details
-
add
Adds the given milliseconds to this object.- Parameters:
millis- the number of milliseconds to add.- Returns:
- this modified object.
-
asgn
Assigns the given LcTime object to this object.- Parameters:
oTime- an existing LcTime object.- Returns:
- this object.
-
format
Formats this object given a time pattern string.- Parameters:
pat- a time pattern string.- Returns:
- the time string formatted according to the given pattern string, upon success, and the empty string, upon error.
-
getDays
public int getDays()Gets this lcTime object's difference in days from Greenwich Mean.- Returns:
- the number of days difference from GMT, or -366 if this object is invalid.
-
getHour
public int getHour()Gets the hour of the day.- Returns:
- the hour of the day in the range 0-23, or -1 if this object is invalid.
-
getLocalTimeFormat
Gets the localized time pattern in the given style for the given locale.- Parameters:
style- a style value:- 0
- requests the locale specific default-style time pattern,
- 1
- requests the locale specific short-style time pattern,
- 2
- requests the locale specific medium-style time pattern,
- 3
- requests the locale specific long-style time pattern, and
- 4
- requests the locale specific full-style time pattern.
locale- a locale string. When empty, it will default to the default locale.- Returns:
- the requested time string.
-
getMillis
public int getMillis()Gets the number of milliseconds since the epoch.- Returns:
- the number of milliseconds, or 0 if this object is invalid.
-
getMilliSecond
public int getMilliSecond()Gets the fraction of the second.- Returns:
- the fraction of the second in the range 0-999, or -1 if this LcTime object is invalid.
-
getMinute
public int getMinute()Gets the minute of the hour.- Returns:
- the minute of the hour in the range 0-59, or -1 if this object is invalid.
-
getSecond
public int getSecond()Gets the second of the hour.- Returns:
- the second of the hour in the range 0-59, or -1 if this object is invalid.
-
getTimeFormat
Gets the time pattern in the given style for the given locale.- Parameters:
style- a style value:- 0
- requests the locale specific default-style time pattern,
- 1
- requests the locale specific short-style time pattern,
- 2
- requests the locale specific medium-style time pattern,
- 3
- requests the locale specific long-style time pattern, and
- 4
- requests the locale specific full-style time pattern.
locale- a locale string. When empty, it will default to the default locale.- Returns:
- the requested time string.
-
getTimeZone
public int getTimeZone()Get timezone in minutes west of Greenwich- Returns:
- timezone.
-
isValid
public boolean isValid()Determines if this object is valid.- Returns:
- boolean true if valid, and false otherwise.
-
setGMTime
public void setGMTime()Sets this object to operate on Greenwich Mean time, which is the default. Any subsequent calls to the format method will result in time strings that are expressed in Greenwich Mean time. -
setLocalTime
public void setLocalTime()Sets this object to operate on local time as opposed to the default, which is Greenwich Mean time. Any subsequent calls to the format method will result in time strings that are expressed in local time. -
toString
Formats this object according to the default pattern.
-