public class ZmanimFormatter extends Object
Date times generated by the Zmanim package as well as Dates. For
example the AstronomicalCalendar.getTemporalHour() returns the length of the hour in
milliseconds. This class can format this time.| Modifier and Type | Field and Description |
|---|---|
static int |
DECIMAL_FORMAT
Format using standard decimal format with 5 positions after the decimal.
|
static long |
HOUR_MILLIS
constant for milliseconds in an hour (3,600,000)
|
(package private) static long |
MINUTE_MILLIS
constant for milliseconds in a minute (60,000)
|
static int |
SEXAGESIMAL_FORMAT
Format using hours and minutes.
|
static int |
SEXAGESIMAL_MILLIS_FORMAT
Format using hours, minutes, seconds and milliseconds.
|
static int |
SEXAGESIMAL_SECONDS_FORMAT
Format using hours, minutes and seconds.
|
static int |
SEXAGESIMAL_XSD_FORMAT
Format using hours, minutes, seconds and milliseconds using the xsd:time format.
|
static int |
XSD_DURATION_FORMAT
Format using the XSD Duration format.
|
| Constructor and Description |
|---|
ZmanimFormatter(int format,
SimpleDateFormat dateFormat,
TimeZone timeZone)
ZmanimFormatter constructor using a formatter
|
ZmanimFormatter(TimeZone timeZone)
constructor that defaults to this will use the format "h:mm:ss" for dates and 00.00.00.0 for
Time. |
| Modifier and Type | Method and Description |
|---|---|
String |
format(double milliseconds)
A method that formats milliseconds into a time format.
|
String |
format(int millis)
A method that formats milliseconds into a time format.
|
String |
format(Time time)
A method that formats
Timeobjects. |
String |
formatDateTime(Date dateTime,
Calendar calendar)
Formats a date using this classe's
date format. |
String |
formatXSDDurationTime(long millis)
This returns the xml representation of an xsd:duration object.
|
String |
formatXSDDurationTime(Time time)
This returns the xml representation of an xsd:duration object.
|
SimpleDateFormat |
getDateFormat() |
TimeZone |
getTimeZone() |
String |
getXSDateTime(Date dateTime,
Calendar cal)
The date:date-time function returns the current date and time as a date/time string.
|
void |
setDateFormat(SimpleDateFormat sdf) |
void |
setTimeFormat(int format)
Sets the format to use for formatting.
|
void |
setTimeZone(TimeZone timeZone) |
static String |
toXML(AstronomicalCalendar ac)
A method that returns an XML formatted
String representing the serialized Object. |
public static final int SEXAGESIMAL_XSD_FORMAT
public static final int DECIMAL_FORMAT
public static final int SEXAGESIMAL_FORMAT
public static final int SEXAGESIMAL_SECONDS_FORMAT
public static final int SEXAGESIMAL_MILLIS_FORMAT
static final long MINUTE_MILLIS
public static final long HOUR_MILLIS
public static final int XSD_DURATION_FORMAT
public ZmanimFormatter(TimeZone timeZone)
Time.public ZmanimFormatter(int format, SimpleDateFormat dateFormat, TimeZone timeZone)
format - int The formatting style to use. Using ZmanimFormatter.SEXAGESIMAL_SECONDS_FORMAT will format the time
time of 90*60*1000 + 1 as 1:30:00public TimeZone getTimeZone()
public void setTimeZone(TimeZone timeZone)
timeZone - the timeZone to setpublic void setTimeFormat(int format)
format - int the format constant to use.public void setDateFormat(SimpleDateFormat sdf)
public SimpleDateFormat getDateFormat()
public String format(double milliseconds)
milliseconds - The time in milliseconds.Stringpublic String format(int millis)
millis - The time in milliseconds.Stringpublic String format(Time time)
Timeobjects.time - The time Object to be formatted.Stringpublic String formatDateTime(Date dateTime, Calendar calendar)
date format.dateTime - the date to formatcalendar - the Calendar used to help format based on the Calendar's DST and other
settings.public String getXSDateTime(Date dateTime, Calendar cal)
public String formatXSDDurationTime(long millis)
millis - the duration in millisecondspublic String formatXSDDurationTime(Time time)
time - the duration as a Time objectpublic static String toXML(AstronomicalCalendar ac)
String representing the serialized Object. The
format used is:
<AstronomicalTimes date="1969-02-08" type="net.sourceforge.zmanim.AstronomicalCalendar algorithm="US Naval Almanac Algorithm" location="Lakewood, NJ" latitude="40.095965" longitude="-74.22213" elevation="31.0" timeZoneName="Eastern Standard Time" timeZoneID="America/New_York" timeZoneOffset="-5">
<Sunrise>2007-02-18T06:45:27-05:00</Sunrise>
<TemporalHour>PT54M17.529S</TemporalHour>
...
</AstronomicalTimes>
Note that the output uses the xsd:dateTime format for
times such as sunrise, and xsd:duration format for
times that are a duration such as the length of a
temporal hour. The output of this method is
returned by the toString .String. The format will be:
<AstronomicalTimes date="1969-02-08" type="net.sourceforge.zmanim.AstronomicalCalendar algorithm="US Naval Almanac Algorithm" location="Lakewood, NJ" latitude="40.095965" longitude="-74.22213" elevation="31.0" timeZoneName="Eastern Standard Time" timeZoneID="America/New_York" timeZoneOffset="-5">
<Sunrise>2007-02-18T06:45:27-05:00</Sunrise>
<TemporalHour>PT54M17.529S</TemporalHour>
...
</AstronomicalTimes>
TODO: add proper schema, and support for nulls. XSD duration (for solar hours), should probably return
nil and not PCopyright © 2004 - 2013 Eliyahu Hershfeld. All Rights Reserved. Released under the LGPL 2.1 license