public class TimeUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.text.SimpleDateFormat |
HTTP_DATE_FORMAT |
static long |
MILLIS_IN_DAY |
static int |
SECONDS_IN_DAY |
Constructor and Description |
---|
TimeUtil() |
Modifier and Type | Method and Description |
---|---|
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/time 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 month)
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 long |
parseHttpTime(java.lang.String time)
Parses the HTTP date/time format.
|
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.
|
public static final int SECONDS_IN_DAY
public static final long MILLIS_IN_DAY
public static final java.text.SimpleDateFormat HTTP_DATE_FORMAT
public static int dayOfYear(int year, int month, int day)
public static boolean isLeapYear(int y)
true
if the year is a leap yearpublic static int getMonthLength(int year, int month)
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 checktrue
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 checktrue
if date and time are valid, otherwise false
public static boolean isValidDateTime(DateTimeStamp dts)
dts
- date/time stamptrue
if date and time are valid, otherwise false
public 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
- secondpublic static DateTimeStamp fromJulianDate(double JD)
JD
- julian datepublic static DateTimeStamp fromJulianDate(JulianDateStamp jds)
jds
- julian date stamppublic static int toCalendarMonth(int month)
public static int toCalendarDayOfWeek(int dayOfWeek)
public static java.lang.String formatHttpDate(long millis)
public static long parseHttpTime(java.lang.String time)
-1
if given string
is invalid.Copyright © 2003-2013 Jodd Team