Package sunlabs.brazil.util
Class ClockFormat
java.lang.Object
sunlabs.brazil.util.ClockFormat
This class implements the "strftime" style clock format command.
It decodes the following %X format strings:
- '%%'
- Insert a %.
- '%A'
- Full weekday name (Monday, Tuesday, etc.).
- '%a'
- Abbreviated weekday name (Mon, Tue, etc.).
- '%B'
- Full month name.
- '%C'
- Century (00 - 99).
- '%c'
- Locale specific date and time.
- '%D'
- Date as %m/%d/%y.
- '%d'
- Day of month (01 - 31).
- '%e'
- Day of month (1 - 31), no leading zeros.
- '%H'
- Hour in 24-hour format (00 - 23).
- '%h'
- Abbreviated month name (Jan,Feb,etc.).
- '%I'
- Hour in 12-hour format (01 - 12).
- '%j'
- Day of year (001 - 366).
- '%k'
- Hour in 24-hour format (0 - 23), no leading zeros.
- '%l'
- Hour in 12-hour format (1 - 12), no leading zeros.
- '%M'
- Minute (00 - 59).
- '%m'
- Month number (01 - 12).
- '%n'
- Insert a newline.
- '%p'
- AM/PM indicator.
- '%R'
- Time as %H:%M.
- '%r'
- Time as %I:%M:%S %p.
- '%S'
- Seconds (00 - 59).
- '%s'
- seconds since epoch.
- '%T'
- Time as %H:%M:%S.
- '%t'
- Insert a tab.
- '%U'
- Week of year (01-52), Sunday is first day.
- '%u'
- Weekday number (1 - 7) Sunday = 7.
- '%V'
- ISO 8601 Week Of Year (01 - 53).
- '%W'
- Week of year (01-52), Monday is first day.
- '%w'
- Weekday number (0 - 6) Sunday = 0.
- '%X'
- Locale specific time format.
- '%x'
- Locale specific date format.
- '%Y'
- Year with century (e.g. 1990)
- '%y'
- Year without century (00 - 99).
- '%Z'
- Time zone name.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Formats a time value based on seconds into a human readable string.static boolean
See if a particular timezone is validstatic void
Test main: ClockFormat format ?time? ?zone?
-
Constructor Details
-
ClockFormat
public ClockFormat()
-
-
Method Details
-
format
Formats a time value based on seconds into a human readable string.- Parameters:
clockVal
- Seconds since the epochformat
- The strftime style format string. If format is null, then "%a %b %d %H:%M:%S %Z %Y" is used.zone
- The time zone abbreviation (e.g. GMT, or PST)- Returns:
- The formatted string.
-
haveZone
See if a particular timezone is valid -
main
Test main: ClockFormat format ?time? ?zone?- Throws:
Exception
-