Module : time

Module Overview

This module provides implementations related to time, date, time zones, and durations.

The module has two main types as Time and TimeZone. The Time type represents a time associated with a given time zone. It has time and zone as its attributes. The TimeZone type represents the time zone associated with a given time. It has id and offset as its attributes. An id can be one of the following:

For information on the operations, which you can perform with this module, see the below Functions. For an example on the usage of the operations, see the Time Example.

Patterns for formatting and parsing

The below patterns can be used to generate the formatter string when using the format() and parse() functions.

SymbolMeaningPresentationExamples
GeratextAD; Anno Domini; A
uyearyear2004; 04
yyear-of-erayear2004; 04
Dday-of-yearnumber189
M/Lmonth-of-yearnumber/text7; 07; Jul; July; J
dday-of-monthnumber10
Q/qquarter-of-yearnumber/text3; 03; Q3; 3rd quarter
Yweek-based-yearyear1996; 96
wweek-of-week-based-yearnumber27
Wweek-of-monthnumber4
Eday-of-weektextTue; Tuesday; T
e/clocalized day-of-weeknumber/text2; 02; Tue; Tuesday; T
Fweek-of-monthnumber3
acam-pm-of-daytextPM
hclock-hour-of-am-pm (1-12)number12
Khour-of-am-pm (0-11)number0
kclock-hour-of-am-pm (1-24)number0
Hhour-of-day (0-23)number0
mminute-of-hournumber30
ssecond-of-minutenumber55
Sfraction-of-secondfraction978
Amilli-of-daynumber1234
nnano-of-secondnumber987654321
Nnano-of-daynumber1234000000
Vime-zone IDzone-idAmerica/Los_Angeles; Z; -08:30
ztime-zone namezone-namePacific Standard Time; PST
Olocalized zone-offsetoffset-OGMT+8; GMT+08:00; UTC-08:00
Xzone-offset 'Z' for zerooffset-XZ; -08; -0830; -08:30; -083015; -08:30:15
xzone-offsetoffset-x+0000; -08; -0830; -08:30; -083015; -08:30:15
Zzone-offsetoffset-Z+0000; -0800; -08:00
ppad nextpad modifier1
'escape for textdelimiter
''single quoteliteral'
[optional section start
]optional section end

Records

Detail Details of an error.
Time Represents a particular time with its associated time-zone.
TimeZone Represents the time-zone information associated with a particular time.

Functions

addDuration Add specified durations to the given time value.
createTime Returns the Time object correspoding to the given time components and time-zone.
currentTime Returns the current time value with the default system time-zone.
format Returns the formatted string representation of the given time.
getDate Returns the date representation of the given time.
getDay Returns the date representation of the given time.
getHour Returns the hour representation of the given time.
getMilliSecond Returns the millisecond representation of the given time.
getMinute Returns the minute representation of the given time.
getMonth Returns the month representation of the given time.
getSecond Returns the second representation of the given time.
getTime Returns the time representation of the given time.
getWeekday Returns the weekday representation of the given time.
getYear Returns the year representation of the given time.
nanoTime Returns the current system time in nano seconds.
parse Returns the time for the given string representation based on the given format string.
subtractDuration Subtract specified durations from the given time value.
toString Returns the ISO 8601 string representation of the given time.
toTimeZone Change the time-zone of the given time.

Constants

TIME_ERROR_REASON Specifies the time error, which occurs in the module.
TIME_FORMAT_RFC_1123 Specifies the time format defined by the RFC-1123.

Types

TimeFormat The time format defined by the RFC-1123.

Errors

Error Represents the Time module related error.