org.mbari.util
Class DateConverter

java.lang.Object
  extended byorg.mbari.util.DateConverter

public class DateConverter
extends java.lang.Object

Utilities for converting between diferent types of commonly used scientific date formats

Author:
Brian Schlining

Constructor Summary
DateConverter()
           
 
Method Summary
static int dateToDayOfYear(java.util.Date date)
           
static int dateToDayOfYear(long millis)
           
static java.util.Date doyToDate(double dayOfYear, double year)
          Convert the Day of a Year to a Date object.
static java.util.Date doyToDate(double dayOfYear, int year)
          Convert the Day of a Year to a Date object
static java.util.Date doyToDate(float dayOfYear, int year)
          Convert the Day of a Year to a Date object
static java.util.Date doyToDate(int dayOfYear, int year)
          Convert the Day of a Year to a Date object
static boolean isLeap(double year)
          Check to see if a year is a leap year
static boolean isLeap(int year)
          Check to see if a year is a leap year
static void main(java.lang.String[] args)
          Method declaration
static long serialDaysToUtc(double serialDay)
          Convert from serial days, the format used by matlab, (Serial days.01 jan 0000 00:00:00 = Day 1) to UTC (milliseconds since 01 Jan 1970 00:00:00).
static double toSerialDays(java.util.Date d)
          Convert a date object ot serial days
static double utcToSerialDays(double utc)
          Convert from UTC (milliseconds since 01 Jan 1970 00:00:00) to serial days, the format used by matlab (Serial days.
static double utcToSerialDays(long utc)
          Convert from UTC (milliseconds since 01 Jan 1970 00:00:00) to serial days, the format used by matlab (Serial days.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateConverter

public DateConverter()
Method Detail

doyToDate

public static final java.util.Date doyToDate(double dayOfYear,
                                             double year)
Convert the Day of a Year to a Date object. This method can handle days of the year greater than 365 (or 366 for leap years). It simple wraps the day around to the next year. For example: doyToDate(367, 1999) will return a Date object for Jan 2, 2000. All times must be in GMT.

Parameters:
dayOfYear - The decimal day of the year. Jan 01, 00:00:00 = 1
year - The year
Returns:
A Date object for the dayOfYear specified

doyToDate

public static final java.util.Date doyToDate(int dayOfYear,
                                             int year)
Convert the Day of a Year to a Date object

Parameters:
dayOfYear - The decimal day of the year. Jan 01, 00:00:00 = 1
year - The year
Returns:
A Date object for the dayOfYear specified

doyToDate

public static final java.util.Date doyToDate(float dayOfYear,
                                             int year)
Convert the Day of a Year to a Date object

Parameters:
dayOfYear - The decimal day of the year. Jan 01, 00:00:00 = 1
year - The year
Returns:
A Date object for the dayOfYear specified

doyToDate

public static final java.util.Date doyToDate(double dayOfYear,
                                             int year)
Convert the Day of a Year to a Date object

Parameters:
dayOfYear - The decimal day of the year. Jan 01, 00:00:00 = 1
year - The year
Returns:
A Date object for the dayOfYear specified

utcToSerialDays

public static final double utcToSerialDays(long utc)
Convert from UTC (milliseconds since 01 Jan 1970 00:00:00) to serial days, the format used by matlab (Serial days. 01 jan 0000 00:00:00 = Day 1).

Parameters:
utc - time in UTC
Returns:
Serial day format utilized by matlab

utcToSerialDays

public static final double utcToSerialDays(double utc)
Convert from UTC (milliseconds since 01 Jan 1970 00:00:00) to serial days, the format used by matlab (Serial days. 01 jan 0000 00:00:00 = Day 1).

Parameters:
utc - time in UTC
Returns:
Serial day format utilized by matlab

serialDaysToUtc

public static final long serialDaysToUtc(double serialDay)
Convert from serial days, the format used by matlab, (Serial days.01 jan 0000 00:00:00 = Day 1) to UTC (milliseconds since 01 Jan 1970 00:00:00).

Parameters:
serialDay - The date value to be conerted
Returns:
UTC time

isLeap

public static final boolean isLeap(double year)
Check to see if a year is a leap year

Parameters:
year - The year in question
Returns:
True if the year is a leap year, false otherwise

isLeap

public static final boolean isLeap(int year)
Check to see if a year is a leap year

Parameters:
year - The year in question
Returns:
True if the year is a leap year, false otherwise

toSerialDays

public static double toSerialDays(java.util.Date d)
Convert a date object ot serial days

Parameters:
d - The data oject to be converted
Returns:
Serial date corresponding to the d

main

public static void main(java.lang.String[] args)
Method declaration

Parameters:
args -
See Also:

dateToDayOfYear

public static int dateToDayOfYear(java.util.Date date)

dateToDayOfYear

public static int dateToDayOfYear(long millis)