public final class DateTimeFormatterBuilder extends Object
This allows a DateTimeFormatter
to be created.
All date-time formatters are created ultimately using this builder.
The basic elements of date-time can all be added:
Finally, a shorthand pattern, mostly compatible with java.text.SimpleDateFormat SimpleDateFormat
can be used, see appendPattern(String)
.
In practice, this simply parses the pattern and calls other methods on the builder.
| Constructor and Description |
|---|
DateTimeFormatterBuilder()
Constructs a new instance of the builder.
|
| Modifier and Type | Method and Description |
|---|---|
DateTimeFormatterBuilder |
append(DateTimeFormatter formatter)
Appends all the elements of a formatter to the builder.
|
DateTimeFormatterBuilder |
appendChronologyId()
Appends the chronology ID, such as 'ISO' or 'ThaiBuddhist', to the formatter.
|
DateTimeFormatterBuilder |
appendChronologyText(TextStyle textStyle)
Appends the chronology name to the formatter.
|
DateTimeFormatterBuilder |
appendFraction(TemporalField field,
int minWidth,
int maxWidth,
boolean decimalPoint)
Appends the fractional value of a date-time field to the formatter.
|
DateTimeFormatterBuilder |
appendInstant()
Appends an instant using ISO-8601 to the formatter, formatting fractional
digits in groups of three.
|
DateTimeFormatterBuilder |
appendInstant(int fractionalDigits)
Appends an instant using ISO-8601 to the formatter with control over
the number of fractional digits.
|
DateTimeFormatterBuilder |
appendLiteral(char literal)
Appends a character literal to the formatter.
|
DateTimeFormatterBuilder |
appendLiteral(String literal)
Appends a string literal to the formatter.
|
DateTimeFormatterBuilder |
appendLocalized(FormatStyle dateStyle,
FormatStyle timeStyle)
Appends a localized date-time pattern to the formatter.
|
DateTimeFormatterBuilder |
appendLocalizedOffset(TextStyle style)
Appends the localized zone offset, such as 'GMT+01:00', to the formatter.
|
DateTimeFormatterBuilder |
appendOffset(String pattern,
String noOffsetText)
Appends the zone offset, such as '+01:00', to the formatter.
|
DateTimeFormatterBuilder |
appendOffsetId()
Appends the zone offset, such as '+01:00', to the formatter.
|
DateTimeFormatterBuilder |
appendOptional(DateTimeFormatter formatter)
Appends a formatter to the builder which will optionally format/parse.
|
DateTimeFormatterBuilder |
appendPattern(String pattern)
Appends the elements defined by the specified pattern to the builder.
|
DateTimeFormatterBuilder |
appendText(TemporalField field)
Appends the text of a date-time field to the formatter using the full
text style.
|
DateTimeFormatterBuilder |
appendText(TemporalField field,
Map<Long,String> textLookup)
Appends the text of a date-time field to the formatter using the specified
map to supply the text.
|
DateTimeFormatterBuilder |
appendText(TemporalField field,
TextStyle textStyle)
Appends the text of a date-time field to the formatter.
|
DateTimeFormatterBuilder |
appendValue(TemporalField field)
Appends the value of a date-time field to the formatter using a normal
output style.
|
DateTimeFormatterBuilder |
appendValue(TemporalField field,
int width)
Appends the value of a date-time field to the formatter using a fixed
width, zero-padded approach.
|
DateTimeFormatterBuilder |
appendValue(TemporalField field,
int minWidth,
int maxWidth,
SignStyle signStyle)
Appends the value of a date-time field to the formatter providing full
control over formatting.
|
DateTimeFormatterBuilder |
appendValueReduced(TemporalField field,
int width,
int maxWidth,
ChronoLocalDate baseDate)
Appends the reduced value of a date-time field to the formatter.
|
DateTimeFormatterBuilder |
appendValueReduced(TemporalField field,
int width,
int maxWidth,
int baseValue)
Appends the reduced value of a date-time field to the formatter.
|
DateTimeFormatterBuilder |
appendZoneId()
Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter.
|
DateTimeFormatterBuilder |
appendZoneOrOffsetId()
Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to
the formatter, using the best available zone ID.
|
DateTimeFormatterBuilder |
appendZoneRegionId()
Appends the time-zone region ID, such as 'Europe/Paris', to the formatter,
rejecting the zone ID if it is a
ZoneOffset . |
DateTimeFormatterBuilder |
appendZoneText(TextStyle textStyle)
Appends the time-zone name, such as 'British Summer Time', to the formatter.
|
DateTimeFormatterBuilder |
appendZoneText(TextStyle textStyle,
Set<ZoneId> preferredZones)
Appends the time-zone name, such as 'British Summer Time', to the formatter.
|
static String |
getLocalizedDateTimePattern(FormatStyle dateStyle,
FormatStyle timeStyle,
Chronology chrono,
Locale locale)
Gets the formatting pattern for date and time styles for a locale and chronology.
|
DateTimeFormatterBuilder |
optionalEnd()
Ends an optional section.
|
DateTimeFormatterBuilder |
optionalStart()
Mark the start of an optional section.
|
DateTimeFormatterBuilder |
padNext(int padWidth)
Causes the next added printer/parser to pad to a fixed width using a space.
|
DateTimeFormatterBuilder |
padNext(int padWidth,
char padChar)
Causes the next added printer/parser to pad to a fixed width.
|
DateTimeFormatterBuilder |
parseCaseInsensitive()
Changes the parse style to be case insensitive for the remainder of the formatter.
|
DateTimeFormatterBuilder |
parseCaseSensitive()
Changes the parse style to be case sensitive for the remainder of the formatter.
|
DateTimeFormatterBuilder |
parseDefaulting(TemporalField field,
long value)
Appends a default value for a field to the formatter for use in parsing.
|
DateTimeFormatterBuilder |
parseLenient()
Changes the parse style to be lenient for the remainder of the formatter.
|
DateTimeFormatterBuilder |
parseStrict()
Changes the parse style to be strict for the remainder of the formatter.
|
DateTimeFormatter |
toFormatter()
Completes this builder by creating the
DateTimeFormatter
using the default locale. |
DateTimeFormatter |
toFormatter(Locale locale)
Completes this builder by creating the
DateTimeFormatter
using the specified locale. |
public DateTimeFormatterBuilder()
public static String getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale)
dateStyle
- the FormatStyle for the date, null for time-only patterntimeStyle
- the FormatStyle for the time, null for date-only patternchrono
- the Chronology, non-nulllocale
- the locale, non-nullIllegalArgumentException
- if both dateStyle and timeStyle are nullpublic DateTimeFormatterBuilder parseCaseSensitive()
Parsing can be case sensitive or insensitive - by default it is case sensitive. This method allows the case sensitivity setting of parsing to be changed.
Calling this method changes the state of the builder such that all
subsequent builder method calls will parse text in case sensitive mode.
See parseCaseInsensitive()
for the opposite setting.
The parse case sensitive/insensitive methods may be called at any point
in the builder, thus the parser can swap between case parsing modes
multiple times during the parse.
Since the default is case sensitive, this method should only be used after
a previous call to #parseCaseInsensitive
.
public DateTimeFormatterBuilder parseCaseInsensitive()
Parsing can be case sensitive or insensitive - by default it is case sensitive. This method allows the case sensitivity setting of parsing to be changed.
Calling this method changes the state of the builder such that all
subsequent builder method calls will parse text in case insensitive mode.
See parseCaseSensitive()
for the opposite setting.
The parse case sensitive/insensitive methods may be called at any point
in the builder, thus the parser can swap between case parsing modes
multiple times during the parse.
public DateTimeFormatterBuilder parseStrict()
Parsing can be strict or lenient - by default its strict. This controls the degree of flexibility in matching the text and sign styles.
When used, this method changes the parsing to be strict from this point onwards.
As strict is the default, this is normally only needed after calling parseLenient()
.
The change will remain in force until the end of the formatter that is eventually
constructed or until parseLenient
is called.
public DateTimeFormatterBuilder parseLenient()
Parsing can be strict or lenient - by default its strict.
This controls the degree of flexibility in matching the text and sign styles.
Applications calling this method should typically also call parseCaseInsensitive()
.
When used, this method changes the parsing to be lenient from this point onwards.
The change will remain in force until the end of the formatter that is eventually
constructed or until parseStrict
is called.
public DateTimeFormatterBuilder parseDefaulting(TemporalField field, long value)
This appends an instruction to the builder to inject a default value into the parsed result. This is especially useful in conjunction with optional parts of the formatter.
For example, consider a formatter that parses the year, followed by an optional month, with a further optional day-of-month. Using such a formatter would require the calling code to check whether a full date, year-month or just a year had been parsed. This method can be used to default the month and day-of-month to a sensible value, such as the first of the month, allowing the calling code to always get a date.
During formatting, this method has no effect.
During parsing, the current state of the parse is inspected. If the specified field has no associated value, because it has not been parsed successfully at that point, then the specified value is injected into the parse result. Injection is immediate, thus the field-value pair will be visible to any subsequent elements in the formatter. As such, this method is normally called at the end of the builder.
field
- the field to default the value of, not nullvalue
- the value to default the field topublic DateTimeFormatterBuilder appendValue(TemporalField field)
The value of the field will be output during a format. If the value cannot be obtained then an exception will be thrown.
The value will be printed as per the normal format of an integer value. Only negative numbers will be signed. No padding will be added.
The parser for a variable width value such as this normally behaves greedily,
requiring one digit, but accepting as many digits as possible.
This behavior can be affected by 'adjacent value parsing'.
See appendValue(java.time.temporal.TemporalField, int)
for full details.
field
- the field to append, not nullpublic DateTimeFormatterBuilder appendValue(TemporalField field, int width)
The value of the field will be output during a format. If the value cannot be obtained then an exception will be thrown.
The value will be zero-padded on the left. If the size of the value means that it cannot be printed within the width then an exception is thrown. If the value of the field is negative then an exception is thrown during formatting.
This method supports a special technique of parsing known as 'adjacent value parsing'. This technique solves the problem where a value, variable or fixed width, is followed by one or more fixed length values. The standard parser is greedy, and thus it would normally steal the digits that are needed by the fixed width value parsers that follow the variable width one.
No action is required to initiate 'adjacent value parsing'.
When a call to appendValue
is made, the builder
enters adjacent value parsing setup mode. If the immediately subsequent method
call or calls on the same builder are for a fixed width value, then the parser will reserve
space so that the fixed width values can be parsed.
For example, consider builder.appendValue(YEAR).appendValue(MONTH_OF_YEAR, 2);
The year is a variable width parse of between 1 and 19 digits.
The month is a fixed width parse of 2 digits.
Because these were appended to the same builder immediately after one another,
the year parser will reserve two digits for the month to parse.
Thus, the text '201106' will correctly parse to a year of 2011 and a month of 6.
Without adjacent value parsing, the year would greedily parse all six digits and leave
nothing for the month.
Adjacent value parsing applies to each set of fixed width not-negative values in the parser
that immediately follow any kind of value, variable or fixed width.
Calling any other append method will end the setup of adjacent value parsing.
Thus, in the unlikely event that you need to avoid adjacent value parsing behavior,
simply add the appendValue
to another DateTimeFormatterBuilder
and add that to this builder.
If adjacent parsing is active, then parsing must match exactly the specified number of digits in both strict and lenient modes. In addition, no positive or negative sign is permitted.
field
- the field to append, not nullwidth
- the width of the printed field, from 1 to 19IllegalArgumentException
- if the width is invalidpublic DateTimeFormatterBuilder appendValue(TemporalField field, int minWidth, int maxWidth, SignStyle signStyle)
The value of the field will be output during a format. If the value cannot be obtained then an exception will be thrown.
This method provides full control of the numeric formatting, including zero-padding and the positive/negative sign.
The parser for a variable width value such as this normally behaves greedily,
accepting as many digits as possible.
This behavior can be affected by 'adjacent value parsing'.
See appendValue(java.time.temporal.TemporalField, int)
for full details.
In strict parsing mode, the minimum number of parsed digits is minWidth
and the maximum is maxWidth
.
In lenient parsing mode, the minimum number of parsed digits is one
and the maximum is 19 (except as limited by adjacent value parsing).
If this method is invoked with equal minimum and maximum widths and a sign style of
NOT_NEGATIVE
then it delegates to appendValue(TemporalField,int)
.
In this scenario, the formatting and parsing behavior described there occur.
field
- the field to append, not nullminWidth
- the minimum field width of the printed field, from 1 to 19maxWidth
- the maximum field width of the printed field, from 1 to 19signStyle
- the positive/negative output style, not nullIllegalArgumentException
- if the widths are invalidpublic DateTimeFormatterBuilder appendValueReduced(TemporalField field, int width, int maxWidth, int baseValue)
Since fields such as year vary by chronology, it is recommended to use the
appendValueReduced(TemporalField, int, int, ChronoLocalDate)
date}
variant of this method in most cases. This variant is suitable for
simple fields or working with only the ISO chronology.
For formatting, the width
and maxWidth
are used to
determine the number of characters to format.
If they are equal then the format is fixed width.
If the value of the field is within the range of the baseValue
using
width
characters then the reduced value is formatted otherwise the value is
truncated to fit maxWidth
.
The rightmost characters are output to match the width, left padding with zero.
For strict parsing, the number of characters allowed by width
to maxWidth
are parsed.
For lenient parsing, the number of characters must be at least 1 and less than 10.
If the number of digits parsed is equal to width
and the value is positive,
the value of the field is computed to be the first number greater than
or equal to the baseValue
with the same least significant characters,
otherwise the value parsed is the field value.
This allows a reduced value to be entered for values in range of the baseValue
and width and absolute values can be entered for values outside the range.
For example, a base value of 1980
and a width of 2
will have
valid values from 1980
to 2079
.
During parsing, the text "12"
will result in the value 2012
as that
is the value within the range where the last two characters are "12".
By contrast, parsing the text "1915"
will result in the value 1915
.
field
- the field to append, not nullwidth
- the field width of the printed and parsed field, from 1 to 10maxWidth
- the maximum field width of the printed field, from 1 to 10baseValue
- the base value of the range of valid valuesIllegalArgumentException
- if the width or base value is invalidpublic DateTimeFormatterBuilder appendValueReduced(TemporalField field, int width, int maxWidth, ChronoLocalDate baseDate)
This is typically used for formatting and parsing a two digit year.
The base date is used to calculate the full value during parsing. For example, if the base date is 1950-01-01 then parsed values for a two digit year parse will be in the range 1950-01-01 to 2049-12-31. Only the year would be extracted from the date, thus a base date of 1950-08-25 would also parse to the range 1950-01-01 to 2049-12-31. This behavior is necessary to support fields such as week-based-year or other calendar systems where the parsed value does not align with standard ISO years.
The exact behavior is as follows. Parse the full set of fields and
determine the effective chronology using the last chronology if
it appears more than once. Then convert the base date to the
effective chronology. Then extract the specified field from the
chronology-specific base date and use it to determine the
baseValue
used below.
For formatting, the width
and maxWidth
are used to
determine the number of characters to format.
If they are equal then the format is fixed width.
If the value of the field is within the range of the baseValue
using
width
characters then the reduced value is formatted otherwise the value is
truncated to fit maxWidth
.
The rightmost characters are output to match the width, left padding with zero.
For strict parsing, the number of characters allowed by width
to maxWidth
are parsed.
For lenient parsing, the number of characters must be at least 1 and less than 10.
If the number of digits parsed is equal to width
and the value is positive,
the value of the field is computed to be the first number greater than
or equal to the baseValue
with the same least significant characters,
otherwise the value parsed is the field value.
This allows a reduced value to be entered for values in range of the baseValue
and width and absolute values can be entered for values outside the range.
For example, a base value of 1980
and a width of 2
will have
valid values from 1980
to 2079
.
During parsing, the text "12"
will result in the value 2012
as that
is the value within the range where the last two characters are "12".
By contrast, parsing the text "1915"
will result in the value 1915
.
field
- the field to append, not nullwidth
- the field width of the printed and parsed field, from 1 to 10maxWidth
- the maximum field width of the printed field, from 1 to 10baseDate
- the base date used to calculate the base value for the range
of valid values in the parsed chronology, not nullIllegalArgumentException
- if the width or base value is invalidpublic DateTimeFormatterBuilder appendFraction(TemporalField field, int minWidth, int maxWidth, boolean decimalPoint)
The fractional value of the field will be output including the
preceding decimal point. The preceding value is not output.
For example, the second-of-minute value of 15 would be output as .25
.
The width of the printed fraction can be controlled. Setting the minimum width to zero will cause no output to be generated. The printed fraction will have the minimum width necessary between the minimum and maximum widths - trailing zeroes are omitted. No rounding occurs due to the maximum width - digits are simply dropped.
When parsing in strict mode, the number of parsed digits must be between the minimum and maximum width. When parsing in lenient mode, the minimum width is considered to be zero and the maximum is nine.
If the value cannot be obtained then an exception will be thrown. If the value is negative an exception will be thrown. If the field does not have a fixed set of valid values then an exception will be thrown. If the field value in the date-time to be printed is invalid it cannot be printed and an exception will be thrown.
field
- the field to append, not nullminWidth
- the minimum width of the field excluding the decimal point, from 0 to 9maxWidth
- the maximum width of the field excluding the decimal point, from 1 to 9decimalPoint
- whether to output the localized decimal point symbolIllegalArgumentException
- if the field has a variable set of valid values or
either width is invalidpublic DateTimeFormatterBuilder appendText(TemporalField field)
The text of the field will be output during a format. The value must be within the valid range of the field. If the value cannot be obtained then an exception will be thrown. If the field has no textual representation, then the numeric value will be used.
The value will be printed as per the normal format of an integer value. Only negative numbers will be signed. No padding will be added.
field
- the field to append, not nullpublic DateTimeFormatterBuilder appendText(TemporalField field, TextStyle textStyle)
The text of the field will be output during a format. The value must be within the valid range of the field. If the value cannot be obtained then an exception will be thrown. If the field has no textual representation, then the numeric value will be used.
The value will be printed as per the normal format of an integer value. Only negative numbers will be signed. No padding will be added.
field
- the field to append, not nulltextStyle
- the text style to use, not nullpublic DateTimeFormatterBuilder appendText(TemporalField field, Map<Long,String> textLookup)
The standard text outputting methods use the localized text in the JDK. This method allows that text to be specified directly. The supplied map is not validated by the builder to ensure that formatting or parsing is possible, thus an invalid map may throw an error during later use.
Supplying the map of text provides considerable flexibility in formatting and parsing. For example, a legacy application might require or supply the months of the year as "JNY", "FBY", "MCH" etc. These do not match the standard set of text for localized month names. Using this method, a map can be created which defines the connection between each value and the text:
Map<Long, String> map = new HashMap<>(); map.put(1L, "JNY"); map.put(2L, "FBY"); map.put(3L, "MCH"); ... builder.appendText(MONTH_OF_YEAR, map);
Other uses might be to output the value with a suffix, such as "1st", "2nd", "3rd", or as Roman numerals "I", "II", "III", "IV".
During formatting, the value is obtained and checked that it is in the valid range. If text is not available for the value then it is output as a number. During parsing, the parser will match against the map of text and numeric values.
field
- the field to append, not nulltextLookup
- the map from the value to the textpublic DateTimeFormatterBuilder appendInstant()
Instants have a fixed output format. They are converted to a date-time with a zone-offset of UTC and formatted using the standard ISO-8601 format. With this method, formatting nano-of-second outputs zero, three, six or nine digits digits as necessary. The localized decimal style is not used.
The instant is obtained using INSTANT_SECONDS
and optionally (@code NANO_OF_SECOND). The value of INSTANT_SECONDS
may be outside the maximum range of LocalDateTime
.
The resolver style has no effect on instant parsing.
The end-of-day time of '24:00' is handled as midnight at the start of the following day.
The leap-second time of '23:59:59' is handled to some degree, see
DateTimeFormatter.parsedLeapSecond()
for full details.
An alternative to this method is to format/parse the instant as a single
epoch-seconds value. That is achieved using appendValue(INSTANT_SECONDS)
.
public DateTimeFormatterBuilder appendInstant(int fractionalDigits)
Instants have a fixed output format, although this method provides some control over the fractional digits. They are converted to a date-time with a zone-offset of UTC and printed using the standard ISO-8601 format. The localized decimal style is not used.
The fractionalDigits
parameter allows the output of the fractional
second to be controlled. Specifying zero will cause no fractional digits
to be output. From 1 to 9 will output an increasing number of digits, using
zero right-padding if necessary. The special value -1 is used to output as
many digits as necessary to avoid any trailing zeroes.
When parsing in strict mode, the number of parsed digits must match the fractional digits. When parsing in lenient mode, any number of fractional digits from zero to nine are accepted.
The instant is obtained using INSTANT_SECONDS
and optionally (@code NANO_OF_SECOND). The value of INSTANT_SECONDS
may be outside the maximum range of LocalDateTime
.
The resolver style has no effect on instant parsing.
The end-of-day time of '24:00' is handled as midnight at the start of the following day.
The leap-second time of '23:59:60' is handled to some degree, see
DateTimeFormatter.parsedLeapSecond()
for full details.
An alternative to this method is to format/parse the instant as a single
epoch-seconds value. That is achieved using appendValue(INSTANT_SECONDS)
.
fractionalDigits
- the number of fractional second digits to format with,
from 0 to 9, or -1 to use as many digits as necessarypublic DateTimeFormatterBuilder appendOffsetId()
This appends an instruction to format/parse the offset ID to the builder.
This is equivalent to calling appendOffset("+HH:MM:ss", "Z")
.
public DateTimeFormatterBuilder appendOffset(String pattern, String noOffsetText)
This appends an instruction to format/parse the offset ID to the builder.
During formatting, the offset is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.offset()
.
It will be printed using the format defined below.
If the offset cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, the offset is parsed using the format defined below. If the offset cannot be parsed then an exception is thrown unless the section of the formatter is optional.
The format of the offset is controlled by a pattern which must be one of the following:
+HH
- hour only, ignoring minute and second
+HHmm
- hour, with minute if non-zero, ignoring second, no colon
+HH:mm
- hour, with minute if non-zero, ignoring second, with colon
+HHMM
- hour and minute, ignoring second, no colon
+HH:MM
- hour and minute, ignoring second, with colon
+HHMMss
- hour and minute, with second if non-zero, no colon
+HH:MM:ss
- hour and minute, with second if non-zero, with colon
+HHMMSS
- hour, minute and second, no colon
+HH:MM:SS
- hour, minute and second, with colon
pattern
- the pattern to use, not nullnoOffsetText
- the text to use when the offset is zero, not nullpublic DateTimeFormatterBuilder appendLocalizedOffset(TextStyle style)
This appends a localized zone offset to the builder, the format of the
localized offset is controlled by the specified style
to this method:
full
- formats with localized offset text, such
as 'GMT, 2-digit hour and minute field, optional second field if non-zero,
and colon.
short
- formats with localized offset text,
such as 'GMT, hour without leading zero, optional 2-digit minute and
second if non-zero, and colon.
During formatting, the offset is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.offset()
.
If the offset cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, the offset is parsed using the format defined above. If the offset cannot be parsed then an exception is thrown unless the section of the formatter is optional.
style
- the format style to use, not nullIllegalArgumentException
- if style is neither full
nor short
public DateTimeFormatterBuilder appendZoneId()
This appends an instruction to format/parse the zone ID to the builder.
The zone ID is obtained in a strict manner suitable for ZonedDateTime
.
By contrast, OffsetDateTime
does not have a zone ID suitable
for use with this method, see appendZoneOrOffsetId()
.
During formatting, the zone is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.zoneId()
.
It will be printed using the result of ZoneId.getId()
.
If the zone cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, the text must match a known zone or offset.
There are two types of zone ID, offset-based, such as '+01:30' and
region-based, such as 'Europe/London'. These are parsed differently.
If the parse starts with '+', '-', 'UT', 'UTC' or 'GMT', then the parser
expects an offset-based zone and will not match region-based zones.
The offset ID, such as '+02:30', may be at the start of the parse,
or prefixed by 'UT', 'UTC' or 'GMT'. The offset ID parsing is
equivalent to using appendOffset(String, String)
using the
arguments 'HH:MM:ss' and the no offset string '0'.
If the parse starts with 'UT', 'UTC' or 'GMT', and the parser cannot
match a following offset ID, then ZoneOffset.UTC
is selected.
In all other cases, the list of known region-based zones is used to
find the longest available match. If no match is found, and the parse
starts with 'Z', then ZoneOffset.UTC
is selected.
The parser uses the case sensitive setting.
For example, the following will parse:
"Europe/London" -- ZoneId.of("Europe/London") "Z" -- ZoneOffset.UTC "UT" -- ZoneId.of("UT") "UTC" -- ZoneId.of("UTC") "GMT" -- ZoneId.of("GMT") "+01:30" -- ZoneOffset.of("+01:30") "UT+01:30" -- ZoneOffset.of("+01:30") "UTC+01:30" -- ZoneOffset.of("+01:30") "GMT+01:30" -- ZoneOffset.of("+01:30")
appendZoneRegionId()
public DateTimeFormatterBuilder appendZoneRegionId()
ZoneOffset
.
This appends an instruction to format/parse the zone ID to the builder only if it is a region-based ID.
During formatting, the zone is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.zoneId()
.
If the zone is a ZoneOffset
or it cannot be obtained then
an exception is thrown unless the section of the formatter is optional.
If the zone is not an offset, then the zone will be printed using
the zone ID from ZoneId.getId()
.
During parsing, the text must match a known zone or offset.
There are two types of zone ID, offset-based, such as '+01:30' and
region-based, such as 'Europe/London'. These are parsed differently.
If the parse starts with '+', '-', 'UT', 'UTC' or 'GMT', then the parser
expects an offset-based zone and will not match region-based zones.
The offset ID, such as '+02:30', may be at the start of the parse,
or prefixed by 'UT', 'UTC' or 'GMT'. The offset ID parsing is
equivalent to using appendOffset(String, String)
using the
arguments 'HH:MM:ss' and the no offset string '0'.
If the parse starts with 'UT', 'UTC' or 'GMT', and the parser cannot
match a following offset ID, then ZoneOffset.UTC
is selected.
In all other cases, the list of known region-based zones is used to
find the longest available match. If no match is found, and the parse
starts with 'Z', then ZoneOffset.UTC
is selected.
The parser uses the case sensitive setting.
For example, the following will parse:
"Europe/London" -- ZoneId.of("Europe/London") "Z" -- ZoneOffset.UTC "UT" -- ZoneId.of("UT") "UTC" -- ZoneId.of("UTC") "GMT" -- ZoneId.of("GMT") "+01:30" -- ZoneOffset.of("+01:30") "UT+01:30" -- ZoneOffset.of("+01:30") "UTC+01:30" -- ZoneOffset.of("+01:30") "GMT+01:30" -- ZoneOffset.of("+01:30")
Note that this method is identical to appendZoneId()
except
in the mechanism used to obtain the zone.
Note also that parsing accepts offsets, whereas formatting will never
produce one.
appendZoneId()
public DateTimeFormatterBuilder appendZoneOrOffsetId()
This appends an instruction to format/parse the best available
zone or offset ID to the builder.
The zone ID is obtained in a lenient manner that first attempts to
find a true zone ID, such as that on ZonedDateTime
, and
then attempts to find an offset, such as that on OffsetDateTime
.
During formatting, the zone is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.zone()
.
It will be printed using the result of ZoneId.getId()
.
If the zone cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, the text must match a known zone or offset.
There are two types of zone ID, offset-based, such as '+01:30' and
region-based, such as 'Europe/London'. These are parsed differently.
If the parse starts with '+', '-', 'UT', 'UTC' or 'GMT', then the parser
expects an offset-based zone and will not match region-based zones.
The offset ID, such as '+02:30', may be at the start of the parse,
or prefixed by 'UT', 'UTC' or 'GMT'. The offset ID parsing is
equivalent to using appendOffset(String, String)
using the
arguments 'HH:MM:ss' and the no offset string '0'.
If the parse starts with 'UT', 'UTC' or 'GMT', and the parser cannot
match a following offset ID, then ZoneOffset.UTC
is selected.
In all other cases, the list of known region-based zones is used to
find the longest available match. If no match is found, and the parse
starts with 'Z', then ZoneOffset.UTC
is selected.
The parser uses the case sensitive setting.
For example, the following will parse:
"Europe/London" -- ZoneId.of("Europe/London") "Z" -- ZoneOffset.UTC "UT" -- ZoneId.of("UT") "UTC" -- ZoneId.of("UTC") "GMT" -- ZoneId.of("GMT") "+01:30" -- ZoneOffset.of("+01:30") "UT+01:30" -- ZoneOffset.of("UT+01:30") "UTC+01:30" -- ZoneOffset.of("UTC+01:30") "GMT+01:30" -- ZoneOffset.of("GMT+01:30")
Note that this method is identical to appendZoneId()
except
in the mechanism used to obtain the zone.
appendZoneId()
public DateTimeFormatterBuilder appendZoneText(TextStyle textStyle)
This appends an instruction to format/parse the textual name of the zone to the builder.
During formatting, the zone is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.zoneId()
.
If the zone is a ZoneOffset
it will be printed using the
result of ZoneOffset.getId()
.
If the zone is not an offset, the textual name will be looked up
for the locale set in the DateTimeFormatter
.
If the temporal object being printed represents an instant, then the text
will be the summer or winter time text as appropriate.
If the lookup for text does not find any suitable result, then the
ID
will be printed instead.
If the zone cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, either the textual zone name, the zone ID or the offset
is accepted. Many textual zone names are not unique, such as CST can be
for both "Central Standard Time" and "China Standard Time". In this
situation, the zone id will be determined by the region information from
formatter's locale
and the standard
zone id for that area, for example, America/New_York for the America Eastern
zone. The appendZoneText(TextStyle, Set)
may be used
to specify a set of preferred ZoneId
in this situation.
textStyle
- the text style to use, not nullpublic DateTimeFormatterBuilder appendZoneText(TextStyle textStyle, Set<ZoneId> preferredZones)
This appends an instruction to format/parse the textual name of the zone to the builder.
During formatting, the zone is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.zoneId()
.
If the zone is a ZoneOffset
it will be printed using the
result of ZoneOffset.getId()
.
If the zone is not an offset, the textual name will be looked up
for the locale set in the DateTimeFormatter
.
If the temporal object being printed represents an instant, then the text
will be the summer or winter time text as appropriate.
If the lookup for text does not find any suitable result, then the
ID
will be printed instead.
If the zone cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, either the textual zone name, the zone ID or the offset
is accepted. Many textual zone names are not unique, such as CST can be
for both "Central Standard Time" and "China Standard Time". In this
situation, the zone id will be determined by the region information from
formatter's locale
and the standard
zone id for that area, for example, America/New_York for the America Eastern
zone. This method also allows a set of preferred ZoneId
to be
specified for parsing. The matched preferred zone id will be used if the
textural zone name being parsed is not unique.
If the zone cannot be parsed then an exception is thrown unless the section of the formatter is optional.
textStyle
- the text style to use, not nullpreferredZones
- the set of preferred zone ids, not nullpublic DateTimeFormatterBuilder appendChronologyId()
This appends an instruction to format/parse the chronology ID to the builder.
During formatting, the chronology is obtained using a mechanism equivalent
to querying the temporal with TemporalQueries.chronology()
.
It will be printed using the result of Chronology.getId()
.
If the chronology cannot be obtained then an exception is thrown unless the
section of the formatter is optional.
During parsing, the chronology is parsed and must match one of the chronologies
in Chronology.getAvailableChronologies()
.
If the chronology cannot be parsed then an exception is thrown unless the
section of the formatter is optional.
The parser uses the case sensitive setting.
public DateTimeFormatterBuilder appendChronologyText(TextStyle textStyle)
The calendar system name will be output during a format. If the chronology cannot be obtained then an exception will be thrown.
textStyle
- the text style to use, not nullpublic DateTimeFormatterBuilder appendLocalized(FormatStyle dateStyle, FormatStyle timeStyle)
This appends a localized section to the builder, suitable for outputting a date, time or date-time combination. The format of the localized section is lazily looked up based on four items:
dateStyle
specified to this method
timeStyle
specified to this method
Locale
of the DateTimeFormatter
Chronology
, selecting the best available
DateTimeFormatter.withChronology(Chronology)
.
During parsing, if a chronology has already been parsed, then it is used.
Otherwise the default from DateTimeFormatter.withChronology(Chronology)
is used, with IsoChronology
as the fallback.
Note that this method provides similar functionality to methods on
DateFormat
such as DateFormat.getDateTimeInstance(int, int)
.
dateStyle
- the date style to use, null means no date requiredtimeStyle
- the time style to use, null means no time requiredIllegalArgumentException
- if both the date and time styles are nullpublic DateTimeFormatterBuilder appendLiteral(char literal)
This character will be output during a format.
literal
- the literal to append, not nullpublic DateTimeFormatterBuilder appendLiteral(String literal)
This string will be output during a format.
If the literal is empty, nothing is added to the formatter.
literal
- the literal to append, not nullpublic DateTimeFormatterBuilder append(DateTimeFormatter formatter)
This method has the same effect as appending each of the constituent parts of the formatter directly to this builder.
formatter
- the formatter to add, not nullpublic DateTimeFormatterBuilder appendOptional(DateTimeFormatter formatter)
This method has the same effect as appending each of the constituent
parts directly to this builder surrounded by an optionalStart()
and
optionalEnd()
.
The formatter will format if data is available for all the fields contained within it. The formatter will parse if the string matches, otherwise no error is returned.
formatter
- the formatter to add, not nullpublic DateTimeFormatterBuilder appendPattern(String pattern)
All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The characters '#', '{' and '}' are reserved for future use. The characters '[' and ']' indicate optional patterns. The following pattern letters are defined:
Symbol Meaning Presentation Examples ------ ------- ------------ ------- G era text AD; Anno Domini; A u year year 2004; 04 y year-of-era year 2004; 04 D day-of-year number 189 M/L month-of-year number/text 7; 07; Jul; July; J d day-of-month number 10 Q/q quarter-of-year number/text 3; 03; Q3; 3rd quarter Y week-based-year year 1996; 96 w week-of-week-based-year number 27 W week-of-month number 4 E day-of-week text Tue; Tuesday; T e/c localized day-of-week number/text 2; 02; Tue; Tuesday; T F week-of-month number 3 a am-pm-of-day text PM h clock-hour-of-am-pm (1-12) number 12 K hour-of-am-pm (0-11) number 0 k clock-hour-of-am-pm (1-24) number 0 H hour-of-day (0-23) number 0 m minute-of-hour number 30 s second-of-minute number 55 S fraction-of-second fraction 978 A milli-of-day number 1234 n nano-of-second number 987654321 N nano-of-day number<PHONE_NUMBER> V time-zone ID zone-id America/Los_Angeles; Z; -08:30 z time-zone name zone-name Pacific Standard Time; PST O localized zone-offset offset-O GMT+8; GMT+08:00; UTC-08:00; X zone-offset 'Z' for zero offset-X Z; -08; -0830; -08:30; -083015; -08:30:15; x zone-offset offset-x +0000; -08; -0830; -08:30; -083015; -08:30:15; Z zone-offset offset-Z +0000; -0800; -08:00; p pad next pad modifier 1 ' escape for text delimiter '' single quote literal ' [ optional section start ] optional section end # reserved for future use { reserved for future use } reserved for future use
The count of pattern letters determine the format. See DateTimeFormatter for a user-focused description of the patterns. The following tables define how the pattern letters map to the builder.
Date fields: Pattern letters to output a date.
Pattern Count Equivalent builder methods ------- ----- -------------------------- G 1 appendText(ChronoField.ERA, TextStyle.SHORT) GG 2 appendText(ChronoField.ERA, TextStyle.SHORT) GGG 3 appendText(ChronoField.ERA, TextStyle.SHORT) GGGG 4 appendText(ChronoField.ERA, TextStyle.FULL) GGGGG 5 appendText(ChronoField.ERA, TextStyle.NARROW) u 1 appendValue(ChronoField.YEAR, 1, 19, SignStyle.NORMAL); uu 2 appendValueReduced(ChronoField.YEAR, 2, 2000); uuu 3 appendValue(ChronoField.YEAR, 3, 19, SignStyle.NORMAL); u..u 4..n appendValue(ChronoField.YEAR, n, 19, SignStyle.EXCEEDS_PAD); y 1 appendValue(ChronoField.YEAR_OF_ERA, 1, 19, SignStyle.NORMAL); yy 2 appendValueReduced(ChronoField.YEAR_OF_ERA, 2, 2000); yyy 3 appendValue(ChronoField.YEAR_OF_ERA, 3, 19, SignStyle.NORMAL); y..y 4..n appendValue(ChronoField.YEAR_OF_ERA, n, 19, SignStyle.EXCEEDS_PAD); Y 1 append special localized WeekFields element for numeric week-based-year YY 2 append special localized WeekFields element for reduced numeric week-based-year 2 digits; YYY 3 append special localized WeekFields element for numeric week-based-year (3, 19, SignStyle.NORMAL); Y..Y 4..n append special localized WeekFields element for numeric week-based-year (n, 19, SignStyle.EXCEEDS_PAD); Q 1 appendValue(IsoFields.QUARTER_OF_YEAR); QQ 2 appendValue(IsoFields.QUARTER_OF_YEAR, 2); QQQ 3 appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.SHORT) QQQQ 4 appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.FULL) QQQQQ 5 appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.NARROW) q 1 appendValue(IsoFields.QUARTER_OF_YEAR); qq 2 appendValue(IsoFields.QUARTER_OF_YEAR, 2); qqq 3 appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.SHORT_STANDALONE) qqqq 4 appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.FULL_STANDALONE) qqqqq 5 appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.NARROW_STANDALONE) M 1 appendValue(ChronoField.MONTH_OF_YEAR); MM 2 appendValue(ChronoField.MONTH_OF_YEAR, 2); MMM 3 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.SHORT) MMMM 4 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL) MMMMM 5 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW) L 1 appendValue(ChronoField.MONTH_OF_YEAR); LL 2 appendValue(ChronoField.MONTH_OF_YEAR, 2); LLL 3 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE) LLLL 4 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL_STANDALONE) LLLLL 5 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW_STANDALONE) w 1 append special localized WeekFields element for numeric week-of-year ww 2 append special localized WeekFields element for numeric week-of-year, zero-padded W 1 append special localized WeekFields element for numeric week-of-month d 1 appendValue(ChronoField.DAY_OF_MONTH) dd 2 appendValue(ChronoField.DAY_OF_MONTH, 2) D 1 appendValue(ChronoField.DAY_OF_YEAR) DD 2 appendValue(ChronoField.DAY_OF_YEAR, 2) DDD 3 appendValue(ChronoField.DAY_OF_YEAR, 3) F 1 appendValue(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH) E 1 appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT) EE 2 appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT) EEE 3 appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT) EEEE 4 appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL) EEEEE 5 appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW) e 1 append special localized WeekFields element for numeric day-of-week ee 2 append special localized WeekFields element for numeric day-of-week, zero-padded eee 3 appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT) eeee 4 appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL) eeeee 5 appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW) c 1 append special localized WeekFields element for numeric day-of-week ccc 3 appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT_STANDALONE) cccc 4 appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL_STANDALONE) ccccc 5 appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW_STANDALONE)
Time fields: Pattern letters to output a time.
A 2..n appendValue(ChronoField.MILLI_OF_DAY, n) n 1 appendValue(ChronoField.NANO_OF_SECOND) n..n 2..n appendValue(ChronoField.NANO_OF_SECOND, n) N 1 appendValue(ChronoField.NANO_OF_DAY) N..N 2..n appendValue(ChronoField.NANO_OF_DAY, n)
Zone ID: Pattern letters to output ZoneId
.
Pattern Count Equivalent builder methods ------- ----- -------------------------- VV 2 appendZoneId() z 1 appendZoneText(TextStyle.SHORT) zz 2 appendZoneText(TextStyle.SHORT) zzz 3 appendZoneText(TextStyle.SHORT) zzzz 4 appendZoneText(TextStyle.FULL)
Zone offset: Pattern letters to output ZoneOffset
.
Pattern Count Equivalent builder methods ------- ----- -------------------------- O 1 appendLocalizedOffsetPrefixed(TextStyle.SHORT); OOOO 4 appendLocalizedOffsetPrefixed(TextStyle.FULL); X 1 appendOffset("+HHmm","Z") XX 2 appendOffset("+HHMM","Z") XXX 3 appendOffset("+HH:MM","Z") XXXX 4 appendOffset("+HHMMss","Z") XXXXX 5 appendOffset("+HH:MM:ss","Z") x 1 appendOffset("+HHmm","+00") xx 2 appendOffset("+HHMM","+0000") xxx 3 appendOffset("+HH:MM","+00:00") xxxx 4 appendOffset("+HHMMss","+0000") xxxxx 5 appendOffset("+HH:MM:ss","+00:00") Z 1 appendOffset("+HHMM","+0000") ZZ 2 appendOffset("+HHMM","+0000") ZZZ 3 appendOffset("+HHMM","+0000") ZZZZ 4 appendLocalizedOffset(TextStyle.FULL); ZZZZZ 5 appendOffset("+HH:MM:ss","Z")
Modifiers: Pattern letters that modify the rest of the pattern:
Pattern Count Equivalent builder methods ------- ----- -------------------------- [ 1 optionalStart() ] 1 optionalEnd() p..p 1..n padNext(n)
Any sequence of letters not specified above, unrecognized letter or reserved character will throw an exception. Future versions may add to the set of patterns. It is recommended to use single quotes around all characters that you want to output directly to ensure that future changes do not break your application.
Note that the pattern string is similar, but not identical, to
SimpleDateFormat
.
The pattern string is also similar, but not identical, to that defined by the
Unicode Common Locale Data Repository (CLDR/LDML).
Pattern letters 'X' and 'u' are aligned with Unicode CLDR/LDML.
By contrast, SimpleDateFormat
uses 'u' for the numeric day of week.
Pattern letters 'y' and 'Y' parse years of two digits and more than 4 digits differently.
Pattern letters 'n', 'A', 'N', and 'p' are added.
Number types will reject large numbers.
pattern
- the pattern to add, not nullIllegalArgumentException
- if the pattern is invalidpublic DateTimeFormatterBuilder padNext(int padWidth)
This padding will pad to a fixed width using spaces.
During formatting, the decorated element will be output and then padded to the specified width. An exception will be thrown during formatting if the pad width is exceeded.
During parsing, the padding and decorated element are parsed. If parsing is lenient, then the pad width is treated as a maximum. The padding is parsed greedily. Thus, if the decorated element starts with the pad character, it will not be parsed.
padWidth
- the pad width, 1 or greaterIllegalArgumentException
- if pad width is too smallpublic DateTimeFormatterBuilder padNext(int padWidth, char padChar)
This padding is intended for padding other than zero-padding. Zero-padding should be achieved using the appendValue methods.
During formatting, the decorated element will be output and then padded to the specified width. An exception will be thrown during formatting if the pad width is exceeded.
During parsing, the padding and decorated element are parsed. If parsing is lenient, then the pad width is treated as a maximum. If parsing is case insensitive, then the pad character is matched ignoring case. The padding is parsed greedily. Thus, if the decorated element starts with the pad character, it will not be parsed.
padWidth
- the pad width, 1 or greaterpadChar
- the pad characterIllegalArgumentException
- if pad width is too smallpublic DateTimeFormatterBuilder optionalStart()
The output of formatting can include optional sections, which may be nested.
An optional section is started by calling this method and ended by calling
optionalEnd()
or by ending the build process.
All elements in the optional section are treated as optional.
During formatting, the section is only output if data is available in the
TemporalAccessor
for all the elements in the section.
During parsing, the whole section may be missing from the parsed string.
For example, consider a builder setup as
builder.appendValue(HOUR_OF_DAY,2).optionalStart().appendValue(MINUTE_OF_HOUR,2)
.
The optional section ends automatically at the end of the builder.
During formatting, the minute will only be output if its value can be obtained from the date-time.
During parsing, the input will be successfully parsed whether the minute is present or not.
public DateTimeFormatterBuilder optionalEnd()
The output of formatting can include optional sections, which may be nested.
An optional section is started by calling optionalStart()
and ended
using this method (or at the end of the builder).
Calling this method without having previously called optionalStart
will throw an exception.
Calling this method immediately after calling optionalStart
has no effect
on the formatter other than ending the (empty) optional section.
All elements in the optional section are treated as optional.
During formatting, the section is only output if data is available in the
TemporalAccessor
for all the elements in the section.
During parsing, the whole section may be missing from the parsed string.
For example, consider a builder setup as
builder.appendValue(HOUR_OF_DAY,2).optionalStart().appendValue(MINUTE_OF_HOUR,2).optionalEnd()
.
During formatting, the minute will only be output if its value can be obtained from the date-time.
During parsing, the input will be successfully parsed whether the minute is present or not.
IllegalStateException
- if there was no previous call to optionalStart
public DateTimeFormatter toFormatter()
DateTimeFormatter
using the default locale.
This will create a formatter with the default FORMAT locale.
Numbers will be printed and parsed using the standard DecimalStyle.
The resolver style will be SMART
.
Calling this method will end any open optional sections by repeatedly
calling optionalEnd()
before creating the formatter.
This builder can still be used after creating the formatter if desired,
although the state may have been changed by calls to optionalEnd
.
public DateTimeFormatter toFormatter(Locale locale)
DateTimeFormatter
using the specified locale.
This will create a formatter with the specified locale.
Numbers will be printed and parsed using the standard DecimalStyle.
The resolver style will be SMART
.
Calling this method will end any open optional sections by repeatedly
calling optionalEnd()
before creating the formatter.
This builder can still be used after creating the formatter if desired,
although the state may have been changed by calls to optionalEnd
.
locale
- the locale to use for formatting, not nullDracula Javadoc Sample, Made with Allan Im.


A native control for playing videos.
The video player is a native view that can be used to play videos, either stored locally or streamed from a web server. The player can occupy the full screen, or can be used as a view that can be added to other views.
Use the Titanium.Media.createVideoPlayer
method to create a video player.
Platform Implementation Notes
All platforms support specifying the video content as a URL, either to a local file or a remote stream. This is done by setting the url property.
On iOS, video content can also be specified as a Blob or File object using the media property.
On iOS, a video player can dynamically switch back and forth between fullscreen mode and standard mode. If the native video controls are displayed, the user can use them to switch between standard and fullscreen mode.
On Android, the video player cannot switch modes. To create a fullscreen player, you
must specify fullscreen: true
when you create the player. This fullscreen player
creates its own Android Activity on top of the activity stack.
Unlike a normal view, this fullscreen video player appears as soon as it is created.
The user can close the player by pressing the Back button. See the code examples for
a sample using the fullscreen player on Android.
There are several known issues with clipping on the Android video player.
-
When used with
scalingMode
set to VIDEO_SCALING_ASPECT_FILL or VIDEO_SCALING_NONE, the video content is not correctly clipped to the boundaries of the view.
(TIMOB-7628) -
When a border is set on the view, the video content does not take the border width into account, so the video content covers the border. (TIMOB-7628)
-
If a borderRadius is specified, the video content is not clipped to the rounded corners. (TIMOB-7629)
| click | Fired when the device detects a click against the view. | |
| complete | Fired when movie playback ends or a user exits playback. | |
| dblclick | Fired when the device detects a double click against the view. | |
| doubletap | Fired when the device detects a double tap against the view. | |
| durationAvailable | This event has been deprecated and renamed durationavailable (lower case). Fired when the video duration is available. | |
| durationavailable | Fired when the video duration is available. | |
| error | Fired when movie playback encounters an error. | |
| fullscreen | Fired when a movie changes to or from fullscreen view. | |
| load | Fired when the movie play loads. | |
| loadstate | Fired when the network loadState changes. | |
| longpress | Fired when the device detects a long press. | |
| mediaTypesAvailable | This event has been deprecated and renamed mediatypesavailable (lower case). Fired when the media types in the current movie are determined. | |
| mediatypesavailable | Fired when the media types in the current movie are determined. | |
| naturalSizeAvailable | This event has been deprecated and renamed naturalsizeavailable (lower case). Fired when the natural size of the current movie is determined. | |
| naturalsizeavailable | Fired when the natural size of the current movie is determined. | |
| playbackState | This event has been deprecated and renamed playbackstate (lower case). Fired when the playbackState changes. | |
| playbackstate | Fired when the playbackState changes. | |
| playing | Fired when the currently playing movie changes. | |
| postlayout | Fired when a layout cycle is finished. | |
| preload | Fired when the movie has preloaded and is ready to play. | |
| resize | Fired when the movie player is resized. | |
| singletap | Fired when the device detects a single tap against the view. | |
| sourceChange | This event has been deprecated and renamed sourcechanged (lower case). Fired when the sourceType property changes. | |
| sourcechange | Fired when the sourceType property changes. | |
| swipe | Fired when the device detects a swipe gesture against the view. | |
| touchcancel | Fired when a touch event is interrupted by the device. | |
| touchend | Fired when a touch event is completed. | |
| touchmove | Fired as soon as the device detects movement of a touch. | |
| touchstart | Fired as soon as the device detects a touch gesture. |
Adds a child to this view's hierarchy.
Arguments
| view | [Titanium.UI.View] | View to add to this view's hierarchy. |
Adds the specified callback as an event listener for the named event.
Arguments
| name | [String] | Name of the event. |
| callback | [Callback<Object>] | Callback function to invoke when the event is fired. |
Animates this view.
Arguments
| animation | [Titanium.UI.AnimationDictionary<Titanium.UI.Animation>] | Either a dictionary of animation properties or an Animation object. |
| callback | [Callback<Object>] | Function to be invoked upon completion of the animation. |
Applies the properties to the proxy.
Arguments
| props | [Dictionary] | A dictionary of properties to apply. |
Translates a point from this view's coordinate system to another view's coordinate system.
Arguments
| point | [Point] | A point in this view's coordinate system. If this argument is missing an x or y property, or the properties can not be converted into numbers, an exception will be raised. |
| destinationView | [Titanium.UI.View] | View that specifies the destination coordinate system to convert to. If this argument is not a view, an exception will be raised. |
Finishes a batch update of the View's layout properties and schedules a layout pass of the view tree.
Fires a synthesized event to any registered listeners.
Arguments
| name | [String] | Name of the event. |
| event | [Dictionary] | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Gets the value of the allowsAirPlay property.
Gets the value of the anchorPoint property.
Gets the value of the animatedCenter property.
Gets the value of the autoplay property.
Gets the value of the backgroundColor property.
Gets the value of the backgroundDisabledColor property.
Gets the value of the backgroundDisabledImage property.
Gets the value of the backgroundFocusedColor property.
Gets the value of the backgroundFocusedImage property.
Gets the value of the backgroundGradient property.
Gets the value of the backgroundImage property.
Gets the value of the backgroundLeftCap property.
Gets the value of the backgroundRepeat property.
Gets the value of the backgroundSelectedColor property.
Gets the value of the backgroundSelectedImage property.
Gets the value of the backgroundTopCap property.
Gets the value of the borderColor property.
Gets the value of the borderRadius property.
Gets the value of the borderWidth property.
Gets the value of the bottom property.
Gets the value of the center property.
Gets the value of the children property.
Gets the value of the currentPlaybackTime property.
Gets the value of the duration property.
Gets the value of the endPlaybackTime property.
Gets the value of the focusable property.
Gets the value of the fullscreen property.
Gets the value of the height property.
Gets the value of the horizontalWrap property.
Gets the value of the initialPlaybackTime property.
Gets the value of the keepScreenOn property.
Gets the value of the layout property.
Gets the value of the left property.
Gets the value of the loadState property.
Gets the value of the mediaControlStyle property.
Gets the value of the mediaTypes property.
Gets the value of the naturalSize property.
Gets the value of the opacity property.
Gets the value of the playableDuration property.
Gets the value of the playbackState property.
Gets the value of the playing property.
Gets the value of the rect property.
Gets the value of the repeatMode property.
Gets the value of the right property.
Gets the value of the scalingMode property.
Gets the value of the size property.
Gets the value of the softKeyboardOnFocus property.
Gets the value of the sourceType property.
Gets the value of the top property.
Gets the value of the touchEnabled property.
Gets the value of the transform property.
Gets the value of the url property.
Gets the value of the useApplicationAudioSession property.
Gets the value of the visible property.
Gets the value of the volume property.
Gets the value of the width property.
Gets the value of the zIndex property.
Removes a child view from this view's hierarchy.
Arguments
| view | [Titanium.UI.View] | View to remove from this view's hierarchy. |
Removes the specified callback as an event listener for the named event.
Arguments
| name | [String] | Name of the event. |
| callback | [Callback<Object>] | Callback function to remove. Must be the same function passed to addEventListener. |
Asynchronously request thumbnail images for one or more points in time in the video.
Arguments
| times | [Array<Number>] | Array of time values, representing offsets into the video, in seconds. |
| option | [Number] | Either Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME or Titanium.Media.VIDEO_TIME_OPTION_EXACT. |
| callback | [Callback<ThumbnailResponse>] | Callback to invoke when a thumbnail is available. |
Sets the value of the allowsAirPlay property.
Arguments
| allowsAirPlay | [Boolean] | New value for the property. |
Sets the value of the anchorPoint property.
Arguments
| anchorPoint | [Point] | New value for the property. |
Sets the value of the autoplay property.
Arguments
| autoplay | [Boolean] | New value for the property. |
Sets the value of the backgroundColor property.
Arguments
| backgroundColor | [String] | New value for the property. |
Sets the value of the backgroundDisabledColor property.
Arguments
| backgroundDisabledColor | [String] | New value for the property. |
Sets the value of the backgroundDisabledImage property.
Arguments
| backgroundDisabledImage | [String] | New value for the property. |
Sets the value of the backgroundFocusedColor property.
Arguments
| backgroundFocusedColor | [String] | New value for the property. |
Sets the value of the backgroundFocusedImage property.
Arguments
| backgroundFocusedImage | [String] | New value for the property. |
Sets the value of the backgroundGradient property.
Arguments
| backgroundGradient | [Gradient] | New value for the property. |
Sets the value of the backgroundImage property.
Arguments
| backgroundImage | [String] | New value for the property. |
Sets the value of the backgroundLeftCap property.
Arguments
| backgroundLeftCap | [Number] | New value for the property. |
Sets the value of the backgroundRepeat property.
Arguments
| backgroundRepeat | [Boolean] | New value for the property. |
Sets the value of the backgroundSelectedColor property.
Arguments
| backgroundSelectedColor | [String] | New value for the property. |
Sets the value of the backgroundSelectedImage property.
Arguments
| backgroundSelectedImage | [String] | New value for the property. |
Sets the value of the backgroundTopCap property.
Arguments
| backgroundTopCap | [Number] | New value for the property. |
Sets the background view for customization which is always displayed behind movie content.
Arguments
| view | [Titanium.UI.View] | View to set. |
Sets the value of the borderColor property.
Arguments
| borderColor | [String] | New value for the property. |
Sets the value of the borderRadius property.
Arguments
| borderRadius | [Number] | New value for the property. |
Sets the value of the borderWidth property.
Arguments
| borderWidth | [Number] | New value for the property. |
Sets the value of the bottom property.
Arguments
| bottom | [NumberString] | New value for the property. |
Sets the value of the center property.
Arguments
| center | [Point] | New value for the property. |
Sets the value of the duration property.
Arguments
| duration | [Number] | New value for the property. |
Sets the value of the endPlaybackTime property.
Arguments
| endPlaybackTime | [Number] | New value for the property. |
Sets the value of the focusable property.
Arguments
| focusable | [Boolean] | New value for the property. |
Sets the value of the fullscreen property.
Arguments
| fullscreen | [Boolean] | New value for the property. |
Sets the value of the height property.
Arguments
| height | [NumberString] | New value for the property. |
Sets the value of the horizontalWrap property.
Arguments
| horizontalWrap | [Boolean] | New value for the property. |
Sets the value of the initialPlaybackTime property.
Arguments
| initialPlaybackTime | [Number] | New value for the property. |
Sets the value of the keepScreenOn property.
Arguments
| keepScreenOn | [Boolean] | New value for the property. |
Sets the value of the layout property.
Arguments
| layout | [String] | New value for the property. |
Sets the value of the left property.
Arguments
| left | [NumberString] | New value for the property. |
Sets the value of the media property.
Arguments
| media | [Titanium.BlobTitanium.Filesystem.FileString] | New value for the property. |
Sets the value of the mediaControlStyle property.
Arguments
| mediaControlStyle | [Number] | New value for the property. |
Sets the value of the mediaTypes property.
Arguments
| mediaTypes | [Number] | New value for the property. |
Sets the value of the naturalSize property.
Arguments
| naturalSize | [MovieSize] | New value for the property. |
Sets the value of the opacity property.
Arguments
| opacity | [Number] | New value for the property. |
Sets the value of the repeatMode property.
Arguments
| repeatMode | [Number] | New value for the property. |
Sets the value of the right property.
Arguments
| right | [NumberString] | New value for the property. |
Sets the value of the scalingMode property.
Arguments
| scalingMode | [Number] | New value for the property. |
Sets the value of the softKeyboardOnFocus property.
Arguments
| softKeyboardOnFocus | [Number] | New value for the property. |
Sets the value of the sourceType property.
Arguments
| sourceType | [Number] | New value for the property. |
Sets the value of the top property.
Arguments
| top | [NumberString] | New value for the property. |
Sets the value of the touchEnabled property.
Arguments
| touchEnabled | [Boolean] | New value for the property. |
Sets the value of the transform property.
Arguments
| transform | [Titanium.UI.2DMatrixTitanium.UI.3DMatrix] | New value for the property. |
Sets the value of the url property.
Arguments
| url | [StringArray<String>] | New value for the property. |
Sets the value of the useApplicationAudioSession property.
Arguments
| useApplicationAudioSession | [Boolean] | New value for the property. |
Sets the value of the visible property.
Arguments
| visible | [Boolean] | New value for the property. |
Sets the value of the volume property.
Arguments
| volume | [Number] | New value for the property. |
Sets the value of the width property.
Arguments
| width | [NumberString] | New value for the property. |
Sets the value of the zIndex property.
Arguments
| zIndex | [Number] | New value for the property. |
Returns a thumbnail image for the video at the specified time.
Arguments
| time | [Number] | Playback time, in seconds. |
| option | [Number] | Either Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME or Titanium.Media.VIDEO_TIME_OPTION_EXACT. |
Returns an image of the rendered view, as a Blob.
Arguments
| callback | [Callback<Titanium.Blob>] | Function to be invoked upon completion. If non-null, this method will be performed asynchronously. If null, it will be performed immediately. |
| honorScaleFactor | [Boolean] | Determines whether the image is scaled based on scale factor of main screen. (iOS only) When set to true, image is scale factor is honored. When set to false, the image in the blob has the same dimensions for retina and non-retina devices. |
Performs a batch update of all supplied layout properties and schedules a layout pass after they have been updated.
Arguments
| params | [Dictionary] | Layout properties to be updated. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| reason |
[Number] Reason that playback ended, one of: VIDEO_FINISH_REASON_PLAYBACK_ENDED, VIDEO_FINISH_REASON_PLAYBACK_ERROR, or VIDEO_FINISH_REASON_USER_EXITED. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| duration |
[Number] Video duration, in milliseconds. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| duration |
[Number] Video duration, in milliseconds. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| message |
[String] Reason for error as a string. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| duration |
[Number] Duration of the animated transition to or from fullscreen mode, in seconds. |
| entering |
[Boolean]
|
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| loadState |
[Number] Current value of the loadState property. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| mediaTypes |
[Number] Current value of the mediaTypes property. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| mediaTypes |
[Number] Current value of the mediaTypes property. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| naturalSize |
[Number] Current value of the naturalSize property. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| naturalSize |
[Number] Current value of the naturalSize property. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| playbackState |
[Number] Current value of the playbackState property,
such as |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| playbackState |
[Number] Current value of the playbackState property,
such as |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| url |
[String] URL of the media. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| source |
[Object] Source object that fired the event. |
| sourceType |
New |
| type |
[String] Name of the event fired. |
Event properties
| source |
[Object] Source object that fired the event. |
| sourceType |
New |
| type |
[String] Name of the event fired. |
Event properties
| direction |
[String] Direction of the swipe--either 'left', 'right', 'up', or 'down'. |
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event's endpoint from the |
| y |
[Number] Y coordinate of the event's endpoint from the |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |
Event properties
| source |
[Object] Source object that fired the event. |
| type |
[String] Name of the event fired. |
| x |
[Number] X coordinate of the event from the |
| y |
[Number] Y coordinate of the event from the |


--- title: gMLP keywords: fastai sidebar: home_sidebar summary: "This is an unofficial PyTorch implementation based on **Liu, H., Dai, Z., So, D. R., & Le, Q. V. (2021). Pay Attention to MLPs. arXiv preprint arXiv:2105.08050.** and **Cholakov, R., & Kolev, T. (2022). The GatedTabTransformer. An enhanced deep learning architecture for tabular modeling. arXiv preprint arXiv:2201.00199.**" description: "This is an unofficial PyTorch implementation based on **Liu, H., Dai, Z., So, D. R., & Le, Q. V. (2021). Pay Attention to MLPs. arXiv preprint arXiv:2105.08050.** and **Cholakov, R., & Kolev, T. (2022). The GatedTabTransformer. An enhanced deep learning architecture for tabular modeling. arXiv preprint arXiv:2201.00199.**" nb_path: "nbs/103d_models.gMLP.ipynb" ---
bs = 16
c_in = 3
c_out = 2
seq_len = 64
patch_size = 4
xb = torch.rand(bs, c_in, seq_len)
model = gMLP(c_in, c_out, seq_len, patch_size=patch_size)
test_eq(model(xb).shape, (bs, c_out))


R Gretton
Video Reflection (0:44)
Transcript
Working on this project, it really put things in perspective for me, on how close and recent the events of the civil rights movement were to us. Sixty years ago, on this road, Route 40, there were still tons of businesses that practiced segregation, despite the fact it was made illegal at that time. Now (?) made thousands of pamphlets and passed them out all along Route 40, to combat this. I know for some, sixty years ago seems like a very long time, but in the grand scheme of history, 60 years ago was not that long ago. There are still people here who saw the events on Route 40, which is crazy to think about.


Abstract: This session will feature an introduction
to the issues of deregulation from Robert Krause, and presentations from
the panelists on the various issues. The session will end with a panel
discussion on deregulation.
Abstract: Electrical engineers tend to develop their
expertise with pencil and paper, or nowadays, with the computer, oblivious
to the fact that electricity kills and injures thousands of users every
year. Yes, electricity can be a very dangerous byproduct of our modern
technology. This presentation will focus on the design, procedural, and
regulatory aspects of safe electrical engineering. A summary of the various
hazards of electricity will be presented relative to consumer products,
electrical generation and transmission, and electricity in the R&D
laboratory. Biography: Dr. Gordon graduated with his Ph.D. in EE in 1981
from Texas Tech University. He worked for the Department of Energy at Lawrence
Livermore National Labs, at Auburn Univerisity, and is currently a member
of the faculty of Electrical Engineering at the University of Texas at
Arlington. His fields of research include pulsed power, dielectric materials,
compact power sources, space power, and electrical safety. As a result
of working with very dangerous forms of electrical energy he has been involved,
for 15 years, in promoting and teaching in electrical safety. He has lectured
to, and trained over 15,000 R&D electrical workers and has a working
knowledge of most all aspects of electrical safety from consumer safety
(e.g., UL), government requirements (e.g., OSHA), professional guidelines
(e.g., IEEE's NESC), and laboratory safety.
Abstract: The quality of short term hourly load forecasts
with lead times ranging from one hour to several days ahead has a significant
impact on the efficiency of the operation of any electric utility since
many potentially costly decisions such as economic scheduling of generating
capacity, scheduling of fuel purchases, system security assessment, and
planning for energy transactions are based on such forecasts. The importance
of accurate load forecasts will increase in the future because of dramatic
changes occurring in the structure of the electric utility industry due
to deregulation and competition. This environment compels the utilities
to operate at the highest possible efficiency which, as indicate above,
requires accurate load forecasts.
In this session, we will discuss a highly successful artificial neural
network (ANN) based short term hourly load forecaster known as "ANNSTLF."
ANNSTLF which has been developed for the Electric Power Research Institute
is the premier load forecasting program in the nation with over 40 users.
The details of the forecasting engine, features of the program, and results
of performance studies will be presented.
Biography: Alireza Khotanzad received the Ph.D. degree
in electrical engineering from Purdue University, West Lafayette, Indiana,
in 1983. He joined the faculty of the Department of Electrical Engineering
at Southern Methodist University, Dallas, Texas, in 1984, where he is currently
an Associate Professor. Dr. Khotanzad's research interests include artificial
neural networks and their applications to various forecasting problems,
pattern recognition, and signal and image processing. He is an Associate
Editor for Pattern Recognition and served as an Associate Editor for the
IEEE Transactions on Neural Networks from 1995 to 1997.
Dr. Khotanzad received the SMU School of of Engineering and Applied
Science Outstanding Graduate Professor Award in 1993 and 1996. He also
was the recipient of the SMU Sigma Xi Outstanding Faculty Research Award
in 1995. He was elected as the IEEE Dallas Section Engineer of the Year
in 1998. He is a registered Professional Engineer in the state of Texas.
Power Distribution
in Industrial and Municipal Facilities
by
Thomas F. Safford, P.E.,
Black & Veatch
Abstract: This talk will cover power distribution issues
in the design of industrial facilities and municipal facilities. The art
of selecting a distribution system for a facility will be discussed, and
the various considerations will be presented: Type of system ( radial,
loop etc.), Voltage (15 kV, 600 volt etc.), Protection (relaying, fuses,
coordination etc.).
Biography: Mr. Safford is responsible for all electrical
engineering and design for projects performed in the Dallas, San Antonio,
Houston, and Ft. Worth offices of Black & Veatch. His work has
included design of municipal and industrial facilities. Mr. Safford
is experienced in the design of high, medium, and low voltage distribution
systems: co-generation; SCADA and control systems: emergency power systems;
lighting systems; hazardous area applications; and electrical systems studies.
Mr. Safford has a BSEE degree from UT El Paso, is a licensed Professional
Engineer in Texas, Mississippi, & Oklahoma, and has worked for Black
& Veatch since 1985.