Method Summary |
|
public static String | format(long date, String pattern) Format a date/time into a specific pattern.
Parameters: date - the date to format expressed in milliseconds. Parameters: pattern - the pattern to use to format the date. |
public static String | format(Date date, String pattern) Format a date/time into a specific pattern.
Parameters: date - the date to format expressed in milliseconds. Parameters: pattern - the pattern to use to format the date. |
public static String | formatElapsedTime(long millis) Format an elapsed time into a plurialization correct string.
It is limited only to report elapsed time in minutes and
seconds and has the following behavior.
- minutes are not displayed when 0.
|
public static String | getDateForHeader() Returns the current Date in a format suitable for a SMTP date
header. |
public static int | getPhaseOfMoon(Calendar cal) Calculate the phase of the moon for a given date.
Code heavily influenced by hacklib.c in Nethack
The Algorithm:
moon period = 29.53058 days ~= 30, year = 365.2422 days
days moon phase advances on first day of year compared to preceding year
= 365.2422 - 12*29.53058 ~= 11
years in Metonic cycle (time until same phases fall on the same days of
the month) = 18.6 ~= 19
moon phase on first day of year (epact) ~= (11*(year%19) + 18) % 30
(18 as initial condition for 1900)
current phase in days = first day phase + days elapsed in year
6 moons ~= 177 days
177 ~= 8 reported phases * 22
+ 11/22 for rounding
Parameters: cal - the calander. |
public static Date | parseIso8601Date(String datestr) |
public static Date | parseIso8601DateTime(String datestr) |
public static Date | parseIso8601DateTimeOrDate(String datestr) Parse a string as a date using the either the ISO8601_DATETIME
or ISO8601_DATE formats. |