AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.util.Dates Class Reference

Static Public Member Functions

static void DateAdd (Calendar date, int intervalKind, int interval)
 
static void DateAddInMillis (Calendar date, long millis)
 
static Calendar DateValue (String value)
 
static int Day (Calendar date)
 
static long ConvertDuration (long duration, int intervalKind)
 
static String FormatDateTime (Calendar date, String pattern)
 
static String FormatDate (Calendar date, String pattern)
 
static String FormatTime (Calendar date)
 
static Calendar DateInstant (int year, int month, int day)
 
static Calendar TimeInstant (int hour, int minute)
 
static int Hour (Calendar date)
 
static int Minute (Calendar date)
 
static int Month (Calendar date)
 
static String MonthName (Calendar date)
 
static Calendar Now ()
 
static int Second (Calendar date)
 
static long Timer ()
 
static int Weekday (Calendar date)
 
static String WeekdayName (Calendar date)
 
static int Year (Calendar date)
 

Static Public Attributes

static final int DATE_YEAR = Calendar.YEAR
 
static final int DATE_MONTH = Calendar.MONTH
 
static final int DATE_DAY = Calendar.DATE
 
static final int DATE_WEEK = Calendar.WEEK_OF_YEAR
 
static final int DATE_HOUR = Calendar.HOUR_OF_DAY
 
static final int DATE_MINUTE = Calendar.MINUTE
 
static final int DATE_SECOND = Calendar.SECOND
 
static final int DATE_MILLISECOND = Calendar.MILLISECOND
 
static final int DATE_MONDAY = Calendar.MONDAY
 
static final int DATE_TUESDAY = Calendar.TUESDAY
 
static final int DATE_WEDNESDAY = Calendar.WEDNESDAY
 
static final int DATE_THURSDAY = Calendar.THURSDAY
 
static final int DATE_FRIDAY = Calendar.FRIDAY
 
static final int DATE_SATURDAY = Calendar.SATURDAY
 
static final int DATE_SUNDAY = Calendar.SUNDAY
 
static final int DATE_JANUARY = Calendar.JANUARY
 
static final int DATE_FEBRUARY = Calendar.FEBRUARY
 
static final int DATE_MARCH = Calendar.MARCH
 
static final int DATE_APRIL = Calendar.APRIL
 
static final int DATE_MAY = Calendar.MAY
 
static final int DATE_JUNE = Calendar.JUNE
 
static final int DATE_JULY = Calendar.JULY
 
static final int DATE_AUGUST = Calendar.AUGUST
 
static final int DATE_SEPTEMBER = Calendar.SEPTEMBER
 
static final int DATE_OCTOBER = Calendar.OCTOBER
 
static final int DATE_NOVEMBER = Calendar.NOVEMBER
 
static final int DATE_DECEMBER = Calendar.DECEMBER
 

Detailed Description

Implementation of various date and time related runtime functions.

Definition at line 24 of file Dates.java.

Member Function Documentation

◆ ConvertDuration()

static long com.google.appinventor.components.runtime.util.Dates.ConvertDuration ( long  duration,
int  intervalKind 
)
static

Returns the give duration in a specified time unit. Months and Years cannot be supported due to their inconsistency.

Parameters
durationduration to convert time unit
intervalkindtime unit
Returns
duration converted into a different time unit

Definition at line 174 of file Dates.java.

◆ DateAdd()

static void com.google.appinventor.components.runtime.util.Dates.DateAdd ( Calendar  date,
int  intervalKind,
int  interval 
)
static

Adds a time interval to the given date. Adding milliseconds has a separated method because interval in ms is long, not int.

See also
DateAddInMillis()
Parameters
datedate to add to
intervalKindkind of interval
intervalunits to add

Definition at line 79 of file Dates.java.

◆ DateAddInMillis()

static void com.google.appinventor.components.runtime.util.Dates.DateAddInMillis ( Calendar  date,
long  millis 
)
static

Adds an interval of milliseconds to the given date. Unlike other time units, milliseconds are saved as long, not int.

See also
Dates.DateAdd()
Parameters
datedate to add to
millisan interval to add

Definition at line 106 of file Dates.java.

◆ DateInstant()

static Calendar com.google.appinventor.components.runtime.util.Dates.DateInstant ( int  year,
int  month,
int  day 
)
static

Returns the instant of the given date (used in DatePicker component)

Parameters
yearyear of the date
monthmonth of the date
dayday of the date
Returns
Calendar (instant in time)

Definition at line 253 of file Dates.java.

◆ DateValue()

static Calendar com.google.appinventor.components.runtime.util.Dates.DateValue ( String  value)
static

Creates a date from the given string.

Dates must be formatted as follows:
MM/DD/YYYY hh:mm:ss
or
MM/DD/YYYY
or
hh:mm
where MM is the month (01-12), DD the day (01-31), YYYY the year (0000-9999), hh the hours (00-23), mm the minutes (00-59) and ss the seconds (00-59).

Parameters
valuestring to convert
Returns
date

Definition at line 128 of file Dates.java.

◆ Day()

static int com.google.appinventor.components.runtime.util.Dates.Day ( Calendar  date)
static

Returns the day of the month for the given date.

Parameters
datedate to get day of
Returns
day (range 1 - 31)

Definition at line 161 of file Dates.java.

◆ FormatDate()

static String com.google.appinventor.components.runtime.util.Dates.FormatDate ( Calendar  date,
String  pattern 
)
static

Converts and formats an instant into a string of date with the specified pattern.

See also
SimpleDateFormat
Parameters
datedate to format
patternformat of the date e.g. MM/DD/YYYY or MMM d, yyyy
Returns
formatted date

Definition at line 221 of file Dates.java.

◆ FormatDateTime()

static String com.google.appinventor.components.runtime.util.Dates.FormatDateTime ( Calendar  date,
String  pattern 
)
static

Converts and formats an instant into a string of date and time with the specified pattern.

See also
SimpleDateFormat
Parameters
datedate to format
patternformat of the date and time e.g. MM/dd/YYYY hh:mm:ss a, MMM d, yyyy HH:mm
Returns
formatted date

Definition at line 201 of file Dates.java.

◆ FormatTime()

static String com.google.appinventor.components.runtime.util.Dates.FormatTime ( Calendar  date)
static

Converts and formats the given date into a time string.

See also
SimpleDateFormat
Parameters
datedate to format
Returns
formatted date

Definition at line 240 of file Dates.java.

◆ Hour()

static int com.google.appinventor.components.runtime.util.Dates.Hour ( Calendar  date)
static

Returns the hours for the given date.

Parameters
datedate to use hours of
Returns
hours (range 0 - 23)

Definition at line 294 of file Dates.java.

◆ Minute()

static int com.google.appinventor.components.runtime.util.Dates.Minute ( Calendar  date)
static

Returns the minutes for the given date.

Parameters
datedate to use minutes of
Returns
minutes (range 0 - 59)

Definition at line 305 of file Dates.java.

◆ Month()

static int com.google.appinventor.components.runtime.util.Dates.Month ( Calendar  date)
static

Returns the month of the given date.

Parameters
datedate to use month of
Returns
month: DATE_JANUARY, DATE_FEBRUARY, DATE_MARCH, DATE_APRIL, DATE_MAY, DATE_JUNE, DATE_JULY, DATE_AUGUST, DATE_SEPTEMBER, DATE_OCTOBER, DATE_NOVEMBER, DATE_DECEMBER

Definition at line 321 of file Dates.java.

◆ MonthName()

static String com.google.appinventor.components.runtime.util.Dates.MonthName ( Calendar  date)
static

Returns the name of the month for the given date.

Parameters
datedate to use month of
Returns
name of month

Definition at line 332 of file Dates.java.

◆ Now()

static Calendar com.google.appinventor.components.runtime.util.Dates.Now ( )
static

Returns the current date and time.

Returns
current date and time

Definition at line 342 of file Dates.java.

◆ Second()

static int com.google.appinventor.components.runtime.util.Dates.Second ( Calendar  date)
static

Returns the seconds for the given date.

Parameters
datedate to use seconds of
Returns
seconds (range 0 - 59)

Definition at line 353 of file Dates.java.

◆ TimeInstant()

static Calendar com.google.appinventor.components.runtime.util.Dates.TimeInstant ( int  hour,
int  minute 
)
static

Returns the instant of the given time (used in TimePicker component)

Parameters
yearyear of the date
monthmonth of the date
dayday of the date
Returns
Calendar (instant in time)

Definition at line 275 of file Dates.java.

◆ Timer()

static long com.google.appinventor.components.runtime.util.Dates.Timer ( )
static

Returns the current system time in milliseconds.

Returns
current system time in milliseconds

Definition at line 363 of file Dates.java.

◆ Weekday()

static int com.google.appinventor.components.runtime.util.Dates.Weekday ( Calendar  date)
static

Returns the weekday for the given date.

Parameters
datedate to use weekday of
Returns
weekday: DATE_SUNDAY, DATE_MONDAY, DATE_TUESDAY, DATE_WEDNESDAY, DATE_THURSDAY, DATE_FRIDAY, DATE_SATURDAY

Definition at line 377 of file Dates.java.

◆ WeekdayName()

static String com.google.appinventor.components.runtime.util.Dates.WeekdayName ( Calendar  date)
static

Returns the name of the weekday for the given date.

Parameters
datedate to use weekday of
Returns
name of weekday

Definition at line 388 of file Dates.java.

◆ Year()

static int com.google.appinventor.components.runtime.util.Dates.Year ( Calendar  date)
static

Returns the year of the given date.

Parameters
datedate to use year of
Returns
year

Definition at line 399 of file Dates.java.

Member Data Documentation

◆ DATE_APRIL

final int com.google.appinventor.components.runtime.util.Dates.DATE_APRIL = Calendar.APRIL
static

Definition at line 55 of file Dates.java.

◆ DATE_AUGUST

final int com.google.appinventor.components.runtime.util.Dates.DATE_AUGUST = Calendar.AUGUST
static

Definition at line 59 of file Dates.java.

◆ DATE_DAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_DAY = Calendar.DATE
static

Definition at line 31 of file Dates.java.

◆ DATE_DECEMBER

final int com.google.appinventor.components.runtime.util.Dates.DATE_DECEMBER = Calendar.DECEMBER
static

Definition at line 63 of file Dates.java.

◆ DATE_FEBRUARY

final int com.google.appinventor.components.runtime.util.Dates.DATE_FEBRUARY = Calendar.FEBRUARY
static

Definition at line 53 of file Dates.java.

◆ DATE_FRIDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_FRIDAY = Calendar.FRIDAY
static

Definition at line 45 of file Dates.java.

◆ DATE_HOUR

final int com.google.appinventor.components.runtime.util.Dates.DATE_HOUR = Calendar.HOUR_OF_DAY
static

Definition at line 33 of file Dates.java.

◆ DATE_JANUARY

final int com.google.appinventor.components.runtime.util.Dates.DATE_JANUARY = Calendar.JANUARY
static

Months.

Definition at line 52 of file Dates.java.

◆ DATE_JULY

final int com.google.appinventor.components.runtime.util.Dates.DATE_JULY = Calendar.JULY
static

Definition at line 58 of file Dates.java.

◆ DATE_JUNE

final int com.google.appinventor.components.runtime.util.Dates.DATE_JUNE = Calendar.JUNE
static

Definition at line 57 of file Dates.java.

◆ DATE_MARCH

final int com.google.appinventor.components.runtime.util.Dates.DATE_MARCH = Calendar.MARCH
static

Definition at line 54 of file Dates.java.

◆ DATE_MAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_MAY = Calendar.MAY
static

Definition at line 56 of file Dates.java.

◆ DATE_MILLISECOND

final int com.google.appinventor.components.runtime.util.Dates.DATE_MILLISECOND = Calendar.MILLISECOND
static

Definition at line 36 of file Dates.java.

◆ DATE_MINUTE

final int com.google.appinventor.components.runtime.util.Dates.DATE_MINUTE = Calendar.MINUTE
static

Definition at line 34 of file Dates.java.

◆ DATE_MONDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_MONDAY = Calendar.MONDAY
static

Days of the week.

Definition at line 41 of file Dates.java.

◆ DATE_MONTH

final int com.google.appinventor.components.runtime.util.Dates.DATE_MONTH = Calendar.MONTH
static

Definition at line 30 of file Dates.java.

◆ DATE_NOVEMBER

final int com.google.appinventor.components.runtime.util.Dates.DATE_NOVEMBER = Calendar.NOVEMBER
static

Definition at line 62 of file Dates.java.

◆ DATE_OCTOBER

final int com.google.appinventor.components.runtime.util.Dates.DATE_OCTOBER = Calendar.OCTOBER
static

Definition at line 61 of file Dates.java.

◆ DATE_SATURDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_SATURDAY = Calendar.SATURDAY
static

Definition at line 46 of file Dates.java.

◆ DATE_SECOND

final int com.google.appinventor.components.runtime.util.Dates.DATE_SECOND = Calendar.SECOND
static

Definition at line 35 of file Dates.java.

◆ DATE_SEPTEMBER

final int com.google.appinventor.components.runtime.util.Dates.DATE_SEPTEMBER = Calendar.SEPTEMBER
static

Definition at line 60 of file Dates.java.

◆ DATE_SUNDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_SUNDAY = Calendar.SUNDAY
static

Definition at line 47 of file Dates.java.

◆ DATE_THURSDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_THURSDAY = Calendar.THURSDAY
static

Definition at line 44 of file Dates.java.

◆ DATE_TUESDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_TUESDAY = Calendar.TUESDAY
static

Definition at line 42 of file Dates.java.

◆ DATE_WEDNESDAY

final int com.google.appinventor.components.runtime.util.Dates.DATE_WEDNESDAY = Calendar.WEDNESDAY
static

Definition at line 43 of file Dates.java.

◆ DATE_WEEK

final int com.google.appinventor.components.runtime.util.Dates.DATE_WEEK = Calendar.WEEK_OF_YEAR
static

Definition at line 32 of file Dates.java.

◆ DATE_YEAR

final int com.google.appinventor.components.runtime.util.Dates.DATE_YEAR = Calendar.YEAR
static

Date/time interval kinds.

Definition at line 29 of file Dates.java.


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