AI2 Component
(Version nb184)
|
Public Member Functions | |
Clock (ComponentContainer container) | |
Clock () | |
void | Timer () |
int | TimerInterval () |
void | TimerInterval (int interval) |
boolean | TimerEnabled () |
void | TimerEnabled (boolean enabled) |
boolean | TimerAlwaysFires () |
void | TimerAlwaysFires (boolean always) |
void | alarm () |
Calendar | MakeDate (int year, int month, int day) |
Calendar | MakeTime (int hour, int minute, int second) |
Calendar | MakeInstantFromParts (int year, int month, int day, int hour, int minute, int second) |
void | onStop () |
void | onResume () |
void | onDestroy () |
void | onDelete () |
Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent | |
HandlesEventDispatching | getDispatchDelegate () |
Static Public Member Functions | |
static long | SystemTime () |
static Calendar | Now () |
static Calendar | MakeInstant (String from) |
static Calendar | MakeInstantFromMillis (long millis) |
static long | GetMillis (Calendar instant) |
static Calendar | AddDuration (Calendar instant, long quantity) |
static Calendar | AddSeconds (Calendar instant, int quantity) |
static Calendar | AddMinutes (Calendar instant, int quantity) |
static Calendar | AddHours (Calendar instant, int quantity) |
static Calendar | AddDays (Calendar instant, int quantity) |
static Calendar | AddWeeks (Calendar instant, int quantity) |
static Calendar | AddMonths (Calendar instant, int quantity) |
static Calendar | AddYears (Calendar instant, int quantity) |
static long | Duration (Calendar start, Calendar end) |
static long | DurationToSeconds (long duration) |
static long | DurationToMinutes (long duration) |
static long | DurationToHours (long duration) |
static long | DurationToDays (long duration) |
static long | DurationToWeeks (long duration) |
static int | Second (Calendar instant) |
static int | Minute (Calendar instant) |
static int | Hour (Calendar instant) |
static int | DayOfMonth (Calendar instant) |
static int | Weekday (Calendar instant) |
static String | WeekdayName (Calendar instant) |
static int | Month (Calendar instant) |
static String | MonthName (Calendar instant) |
static int | Year (Calendar instant) |
static String | FormatDateTime (Calendar instant, String pattern) |
static String | FormatDate (Calendar instant, String pattern) |
static String | FormatTime (Calendar instant) |
Additional Inherited Members | |
Static Public Attributes inherited from com.google.appinventor.components.runtime.Component | |
static final String | ASSET_DIRECTORY = "component" |
static final int | ALIGNMENT_NORMAL = 0 |
static final int | ALIGNMENT_CENTER = 1 |
static final int | ALIGNMENT_OPPOSITE = 2 |
static final int | ACCELEROMETER_SENSITIVITY_WEAK = 1 |
static final int | ACCELEROMETER_SENSITIVITY_MODERATE = 2 |
static final int | ACCELEROMETER_SENSITIVITY_STRONG = 3 |
static final int | BUTTON_SHAPE_DEFAULT = 0 |
static final int | BUTTON_SHAPE_ROUNDED = 1 |
static final int | BUTTON_SHAPE_RECT = 2 |
static final int | BUTTON_SHAPE_OVAL = 3 |
static final int | COLOR_NONE = 0x00FFFFFF |
static final int | COLOR_BLACK = 0xFF000000 |
static final int | COLOR_BLUE = 0xFF0000FF |
static final int | COLOR_CYAN = 0xFF00FFFF |
static final int | COLOR_DKGRAY = 0xFF444444 |
static final int | COLOR_GRAY = 0xFF888888 |
static final int | COLOR_GREEN = 0xFF00FF00 |
static final int | COLOR_LTGRAY = 0xFFCCCCCC |
static final int | COLOR_MAGENTA = 0xFFFF00FF |
static final int | COLOR_ORANGE = 0xFFFFC800 |
static final int | COLOR_PINK = 0xFFFFAFAF |
static final int | COLOR_RED = 0xFFFF0000 |
static final int | COLOR_WHITE = 0xFFFFFFFF |
static final int | COLOR_YELLOW = 0xFFFFFF00 |
static final int | COLOR_DEFAULT = 0x00000000 |
static final String | DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF" |
static final String | DEFAULT_VALUE_COLOR_BLACK = "&HFF000000" |
static final String | DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF" |
static final String | DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF" |
static final String | DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444" |
static final String | DEFAULT_VALUE_COLOR_GRAY = "&HFF888888" |
static final String | DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00" |
static final String | DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC" |
static final String | DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF" |
static final String | DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800" |
static final String | DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF" |
static final String | DEFAULT_VALUE_COLOR_RED = "&HFFFF0000" |
static final String | DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF" |
static final String | DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00" |
static final String | DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000" |
static final float | FONT_DEFAULT_SIZE = 14 |
static final int | LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL |
static final int | LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL |
static final int | SCALING_SCALE_PROPORTIONALLY = 0 |
static final int | SCALING_SCALE_TO_FIT = 1 |
static final int | TYPEFACE_DEFAULT = 0 |
static final int | TYPEFACE_SANSSERIF = 1 |
static final int | TYPEFACE_SERIF = 2 |
static final int | TYPEFACE_MONOSPACE = 3 |
static final int | LENGTH_PREFERRED = -1 |
static final int | LENGTH_FILL_PARENT = -2 |
static final int | LENGTH_UNKNOWN = -3 |
static final int | LENGTH_PERCENT_TAG = -1000 |
static final int | TOAST_LENGTH_SHORT = 0 |
static final int | TOAST_LENGTH_LONG = 1 |
static final int | DIRECTION_NORTH = 1 |
static final int | DIRECTION_NORTHEAST = 2 |
static final int | DIRECTION_EAST = 3 |
static final int | DIRECTION_SOUTHEAST = 4 |
static final int | DIRECTION_SOUTH = -1 |
static final int | DIRECTION_SOUTHWEST = -2 |
static final int | DIRECTION_WEST = -3 |
static final int | DIRECTION_NORTHWEST = -4 |
static final int | DIRECTION_NONE = 0 |
static final int | DIRECTION_MIN = -4 |
static final int | DIRECTION_MAX = 4 |
static float | SLIDER_MIN_VALUE = 10 |
static float | SLIDER_MAX_VALUE = 50 |
static float | SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f |
static final String | DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = "" |
static final String | DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = "" |
Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent | |
AndroidNonvisibleComponent (Form form) | |
Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent | |
final Form | form |
Non-visible component that provides the instant in time using the internal clock on the phone. It can fire a timer at regularly set intervals and perform time calculations, manipulations, and conversions.
Operations on dates and times, such as from DatePicker
and TimePicker
, are accomplished through methods in Clock. Date and Time are represented as InstantInTime and Duration.
Instants are assumed to be in the device's local time zone. When they are converted to or from milliseconds, the milliseconds for a given Instance are calculated from January 1, 1970 in UTC (Greenwich Mean Time).
Methods to convert an Instant to text are also available. Acceptable patterns are empty string, MM/dd/YYYY HH:mm:ss a
, or MMM d, yyyy HH:mm
. The empty string will provide the default format, which is "MMM d, yyyy HH:mm:ss a"
for FormatDateTime(Calendar, String), "MMM d, yyyy"
for FormatDate(Calendar, String). To see all possible formats, please see here.
A note on combining date and time: In order to combine the date from one Instant and the time from another, for example from a DatePicker
and TimePicker
, extract the parts as text and use the text to create a new Instant. For example:
Definition at line 73 of file Clock.java.
com.google.appinventor.components.runtime.Clock.Clock | ( | ComponentContainer | container | ) |
Creates a new Clock component.
container | ignored (because this is a non-visible component) |
Definition at line 88 of file Clock.java.
com.google.appinventor.components.runtime.Clock.Clock | ( | ) |
Definition at line 105 of file Clock.java.
|
static |
Definition at line 401 of file Clock.java.
|
static |
Definition at line 373 of file Clock.java.
|
static |
Definition at line 394 of file Clock.java.
|
static |
Definition at line 387 of file Clock.java.
|
static |
Definition at line 415 of file Clock.java.
|
static |
Definition at line 380 of file Clock.java.
|
static |
Definition at line 408 of file Clock.java.
|
static |
Definition at line 422 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.alarm | ( | ) |
Implements com.google.appinventor.components.runtime.AlarmHandler.
Definition at line 208 of file Clock.java.
|
static |
Returns the day of the month.
instant | instant to use day of the month of |
Definition at line 536 of file Clock.java.
|
static |
Returns the milliseconds by which end follows start (+ or -)
start | beginning instant |
end | ending instant |
Definition at line 437 of file Clock.java.
|
static |
Returns the duration converted from milliseconds to days.
duration | time interval to convert |
Definition at line 481 of file Clock.java.
|
static |
Returns the duration converted from milliseconds to hours.
duration | time interval to convert |
Definition at line 470 of file Clock.java.
|
static |
Returns the duration converted from milliseconds to minutes.
duration | time interval to convert |
Definition at line 459 of file Clock.java.
|
static |
Returns the duration converted from milliseconds to seconds.
duration | time interval to convert |
Definition at line 448 of file Clock.java.
|
static |
Returns the duration converted from milliseconds to weeks.
duration | time interval to convert |
Definition at line 492 of file Clock.java.
|
static |
Converts and formats an instant into a string of date with the specified pattern. To learn more about valid patterns, please see SimpleDateFormat.
instant | instant to format |
pattern | format of the date e.g. MM/DD/YYYY or MMM d, yyyy |
Definition at line 630 of file Clock.java.
|
static |
Converts and formats an instant into a string of date and time with the specified pattern. To learn more about valid patterns, please see SimpleDateFormat.
instant | instant to format |
pattern | format of the date and time e.g. MM/dd/YYYY hh:mm:ss a, MMM d, yyyy HH:mm |
Definition at line 609 of file Clock.java.
|
static |
Converts and formats the given instant into a string with the specified pattern. To learn more about valid patterns, please see SimpleDateFormat.
instant | instant to format |
Definition at line 650 of file Clock.java.
|
static |
Calendar property getter method: gets the raw millisecond representation of a Calendar.
instant | Calendar |
Definition at line 368 of file Clock.java.
|
static |
Returns the hours for the given date.
instant | Calendar to use hours of |
Definition at line 525 of file Clock.java.
Calendar com.google.appinventor.components.runtime.Clock.MakeDate | ( | int | year, |
int | month, | ||
int | day | ||
) |
An instant in time specified by number year, number month, number day
year | year integer |
month | month integer |
day | day integer |
Definition at line 262 of file Clock.java.
|
static |
An instant in time specified by 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).
from | string to convert |
Definition at line 242 of file Clock.java.
|
static |
Create an Calendar from ms since 1/1/1970 00:00:00.0000 Probably should go in Calendar.
millis | raw millisecond number. @suppressdoc |
Definition at line 354 of file Clock.java.
Calendar com.google.appinventor.components.runtime.Clock.MakeInstantFromParts | ( | int | year, |
int | month, | ||
int | day, | ||
int | hour, | ||
int | minute, | ||
int | second | ||
) |
An instant in time specified by number year, number month, number day, number hour, number minute, number second
year | year integer |
month | month integer |
day | day integer |
hour | hour integer |
minute | minute integer |
second | minute integer |
Definition at line 316 of file Clock.java.
Calendar com.google.appinventor.components.runtime.Clock.MakeTime | ( | int | hour, |
int | minute, | ||
int | second | ||
) |
An instant in time specified by integer hour, integer minute, and integer second
hour | hour integer |
minute | minute integer |
second | second integer |
Definition at line 289 of file Clock.java.
|
static |
Returns the minutes for the given date.
instant | instant to use minutes of |
Definition at line 514 of file Clock.java.
|
static |
Returns the number of the month for the given instant.
instant | instant to use month of |
Definition at line 571 of file Clock.java.
|
static |
Returns the name of the month for the given instant.
instant | instant to use month of |
Definition at line 583 of file Clock.java.
|
static |
Definition at line 225 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.onDelete | ( | ) |
Implements com.google.appinventor.components.runtime.Deleteable.
Definition at line 670 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.onDestroy | ( | ) |
Implements com.google.appinventor.components.runtime.OnDestroyListener.
Definition at line 665 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.onResume | ( | ) |
Implements com.google.appinventor.components.runtime.OnResumeListener.
Definition at line 660 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.onStop | ( | ) |
Implements com.google.appinventor.components.runtime.OnStopListener.
Definition at line 655 of file Clock.java.
|
static |
Returns the seconds for the given instant.
instant | instant to use seconds of |
Definition at line 503 of file Clock.java.
|
static |
Returns the current system time in milliseconds.
Definition at line 219 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.Timer | ( | ) |
boolean com.google.appinventor.components.runtime.Clock.TimerAlwaysFires | ( | ) |
TimerAlwaysFires property getter method.
@suppressdoc
Definition at line 188 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.TimerAlwaysFires | ( | boolean | always | ) |
TimerAlwaysFires property setter method: instructs when to disable
@suppressdoc
always |
Definition at line 201 of file Clock.java.
boolean com.google.appinventor.components.runtime.Clock.TimerEnabled | ( | ) |
Enabled property getter method.
Definition at line 160 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.TimerEnabled | ( | boolean | enabled | ) |
Specifies whether the Timer() event should run.
enabled |
Definition at line 173 of file Clock.java.
int com.google.appinventor.components.runtime.Clock.TimerInterval | ( | ) |
Interval property getter method.
Definition at line 131 of file Clock.java.
void com.google.appinventor.components.runtime.Clock.TimerInterval | ( | int | interval | ) |
Specifies the interval between subsequent Timer() events.
Note: Drift may occur over time and that the system may not honor the timing specified here if the app or another process on the phone is busy.
interval | timer interval in ms |
Definition at line 147 of file Clock.java.
|
static |
Returns the weekday for the given instant.
instant | instant to use day of week of |
Definition at line 548 of file Clock.java.
|
static |
Returns the name of the weekday for the given instant.
instant | instant to use weekday of |
Definition at line 559 of file Clock.java.
|
static |
Returns the year of the given instant.
instant | instant to use year of |
Definition at line 594 of file Clock.java.