|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.datetime.TimeUtil
public class TimeUtil
Date time calculations and utilities. TimeUtil is used by
JDateTime and it contains few utilities that may be used
elsewhere, although JDateTime is recommended for all time
manipulation.
| Field Summary | |
|---|---|
static java.text.SimpleDateFormat |
HTTP_DATE_FORMAT
|
static long |
MILLIS_IN_DAY
|
static int |
SECONDS_IN_DAY
|
| Constructor Summary | |
|---|---|
TimeUtil()
|
|
| Method Summary | |
|---|---|
static int |
dayOfYear(int year,
int month,
int day)
Calculates day of year from given time stamp. |
static java.lang.String |
formatHttpDate(long millis)
Formats time to HTTP date format. |
static DateTimeStamp |
fromJulianDate(double JD)
Calculates time stamp from Astronomical Julian Date. |
static DateTimeStamp |
fromJulianDate(JulianDateStamp jds)
Calculates time stamp from Astronomical Julian Date. |
static int |
getMonthLength(int year,
int m)
Returns the length of the specified month in days. |
static boolean |
isLeapYear(int y)
Check if the given year is leap year. |
static boolean |
isValidDate(int year,
int month,
int day)
Checks if date is valid. |
static boolean |
isValidDateTime(DateTimeStamp dts)
Checks if date and time are valid. |
static boolean |
isValidDateTime(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Checks if date and time are valid. |
static boolean |
isValidTime(int hour,
int minute,
int second,
int millisecond)
Checks if time is valid. |
static int |
toCalendarDayOfWeek(int dayOfWeek)
Returns Calendar day-of-week from provided JDateTime. |
static int |
toCalendarMonth(int month)
Returns Calendar month from provided JDateTime month. |
static JulianDateStamp |
toJulianDate(DateTimeStamp time)
Calculates Astronomical Julian Date from given time stamp. |
static JulianDateStamp |
toJulianDate(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Calculates Astronomical Julian Date from given time. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SECONDS_IN_DAY
public static final long MILLIS_IN_DAY
public static final java.text.SimpleDateFormat HTTP_DATE_FORMAT
| Constructor Detail |
|---|
public TimeUtil()
| Method Detail |
|---|
public static int dayOfYear(int year,
int month,
int day)
public static boolean isLeapYear(int y)
true if the year is a leap year
public static int getMonthLength(int year,
int m)
public static boolean isValidDate(int year,
int month,
int day)
true if date is valid, otherwise false
public static boolean isValidTime(int hour,
int minute,
int second,
int millisecond)
hour - hour to checkminute - minute to checksecond - second to check
true if time is valid, otherwise false
public static boolean isValidDateTime(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
year - year to checkmonth - month to checkday - day to checkhour - hour to checkminute - minute to checksecond - second to check
true if date and time are valid, otherwise falsepublic static boolean isValidDateTime(DateTimeStamp dts)
dts - date/time stamp
true if date and time are valid, otherwise falsepublic static JulianDateStamp toJulianDate(DateTimeStamp time)
public static JulianDateStamp toJulianDate(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Astronomical Julian Dates are counting from noon of the January 1st, -4712 (julian date 0 is -4712/01/01 12:00:00). Zero year exist. Julian Date is always GMT, there are no timezones.
Algorithm based on Numerical Recipesin C, 2nd ed., Cambridge University Press 1992, modified and enhanced by Igor Spasic.
year - yearmonth - monthday - dayhour - hourminute - minutesecond - second
public static DateTimeStamp fromJulianDate(double JD)
JD - julian date
public static DateTimeStamp fromJulianDate(JulianDateStamp jds)
jds - julian date stamp
public static int toCalendarMonth(int month)
public static int toCalendarDayOfWeek(int dayOfWeek)
public static java.lang.String formatHttpDate(long millis)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||