|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nasa.gsfc.drl.rtstps.core.output.hdf5.PDSDate
public class PDSDate
Manipulate a date given a packet time in the following format, calculate year, day, month, day of year, hour, minute and seconds. The 10 lines of code which calculate year, day, month were taken from getCal in TimeDate in the checker package. The day of year tables were taken from http://disc.gsfc.nasa.gov/julian_calendar.shtml Note: much of this was taken from an earlier implementation in CRECBuilder
Field Summary | |
---|---|
private long |
day
|
private int[][] |
dayInLeapYear
|
private int[][] |
dayInPerpetual
|
private long |
dayOfYear
|
private static long |
DaysBetweenEpochs
|
private static double |
EPOCH_DATE
|
private long |
hours
|
private static long |
MicrosPerDay
|
private static long |
MillisBetweenEpochs
|
private long |
milliseconds
|
private static long |
MillisPerDay
|
private long |
minutes
|
private long |
month
|
private long |
packetTime
|
private long |
rawDay
|
private long |
rawMicros
|
private long |
rawMillis
|
private long |
seconds
|
private long |
year
|
Constructor Summary | |
---|---|
PDSDate(int year,
int month,
int day,
int hour,
int minute,
int second,
int milliseconds,
int microseconds)
Rough approximation into Mission Epoch date/time. |
|
PDSDate(long packetTime)
Constructor, supply a packet time in the following format from epoch 1/1/58. |
Method Summary | |
---|---|
private void |
calculate()
Calculate the new year, month, days of year, hours, minutes, seconds, milliseconds... |
int |
compareTo(PDSDate dateTime)
public static PDSDate createTimeDate(String dateStr, DateFormat dateFormat, String timeStr, DateFormat timeFormat) throws RtStpsException { //System.out.println("The date strings: " + dateStr + " time:" + timeStr); Calendar dateCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); Date date = dateCal.getTime(); date.setTime(0L); try { // NOTE: If the timezone is set to UTC, this seems to add 5 hrs to the value being parsed // So leaving it off, seems to retrieve the hours as they are specified in the string // date = dateFormat.parse(dateStr); } catch (ParseException e) { throw new RtStpsException(e); } dateCal.setTime(date); Calendar timeCal = Calendar.getInstance(TimeZone.getTimeZone("UTC") ); Date time = timeCal.getTime(); time.setTime(0L); try { // NOTE: If the timezone is set to UTC, this seems to add 5 hrs to the value being parsed // So leaving it off, seems to retrieve the hours as they are specified in the string // time = timeFormat.parse(timeStr); } catch (ParseException e) { throw new RtStpsException(e); } timeCal.setTime(time); // PDSDate(int year, int month, int day, int hour, int minute, int second, int milliseconds) { int year = dateCal.get(Calendar.YEAR); int month = dateCal.get(Calendar.MONTH); int dayOfMonth = dateCal.get(Calendar.DAY_OF_MONTH); int hourOfDay = timeCal.get(Calendar.HOUR_OF_DAY); int minute = timeCal.get(Calendar.MINUTE); int second = timeCal.get(Calendar.SECOND); int milliSecond = timeCal.get(Calendar.MILLISECOND); // PDSDate(int year, int month, int day, int hour, int minute, int second, int milliseconds) { /** System.out.println("year: " + year); System.out.println("month: " + month); System.out.println("dayOfMonth: " + dayOfMonth); System.out.println("hourOfDay: " + hourOfDay); System.out.println("minute: " + minute); System.out.println("second: " + second); System.out.println("milliSecond: " + milliSecond); // PDSDate dateTime = new PDSDate(year, month, dayOfMonth, hourOfDay, minute, second, milliSecond); //SimpleDateFormat df = new SimpleDateFormat(); //System.out.println("Created date/time: " + df.format(dateTime.getDate())); // return dateTime; //} |
private int |
dayOfYear(int year,
int month,
int day)
Calculate the day of the year using the calendar tables. |
private int |
daysSinceEpoch(int year)
Count up the days since the epoch per year. |
java.util.Date |
getDate()
Return the Java Date, the epoch is converted and the timezone is UTC The returned Date if simply printed will be relative this your timezone. |
long |
getDayOfMonth()
Get the calculated day of month |
long |
getDayOfYear()
Get the calculated day of the year |
long |
getHours()
Get the calculated hours of day |
long |
getMicroseconds()
Get any remaining microseconds of millisecond |
long |
getMicrosSinceEpoch()
Return the micros since the mission epoch |
static long |
getMicrosSinceEpoch(long packetTime)
Static variation given a 64-bit mission time (segmented) |
long |
getMilliseconds()
Get the calculated milliseconds of second |
long |
getMinutes()
Get the calculated minutes of hour |
long |
getMonth()
Get the calculated month of the year |
long |
getPacketTime()
Return the 64-bit timestamp |
long |
getRawDay()
Get the raw day from the packet time |
long |
getRawMicros()
Get the raw microseconds from the packet time |
long |
getRawMillis()
Get the raw milliseconds from the packet time |
long |
getSeconds()
Get the calculated seconds of minute |
long |
getYear()
Get the calculated year, four digits |
boolean |
isLeapYear(int year)
Determine if this is a leapyear or not |
java.lang.String |
toRawFields()
Return just the raw fields |
static java.lang.String |
toRawFields(long packetTime)
Return just the raw fields, static version |
java.lang.String |
toString()
Convert the results to String |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final double EPOCH_DATE
private static final long MillisPerDay
private static final long MicrosPerDay
private static final long DaysBetweenEpochs
private static final long MillisBetweenEpochs
private int[][] dayInPerpetual
private int[][] dayInLeapYear
private long rawDay
private long rawMillis
private long rawMicros
private long year
private long month
private long day
private long hours
private long minutes
private long seconds
private long milliseconds
private long dayOfYear
private long packetTime
Constructor Detail |
---|
public PDSDate(long packetTime)
Uint16 day since 1/1/1958 Uint32 millisecond of day Uint16 microsecond of millisecond
packetTime
- public PDSDate(int year, int month, int day, int hour, int minute, int second, int milliseconds, int microseconds)
year
- the yearmonth
- the month, starts at 0 for Januaryday
- the day of month, starts at 1hour
- the hour of dayminute
- the minute of the hoursecond
- the seconds in the minutemilliseconds
- the milliseconds of the secondmicrosecond
- of the millisMethod Detail |
---|
public long getPacketTime()
public long getRawDay()
public long getRawMillis()
public long getRawMicros()
public long getMonth()
public long getYear()
public long getDayOfMonth()
public long getDayOfYear()
public long getMilliseconds()
public long getMicroseconds()
public long getSeconds()
public long getMinutes()
public long getHours()
public long getMicrosSinceEpoch()
public static long getMicrosSinceEpoch(long packetTime)
packetTime
- 48 bits of time, 16 bits millis and 16 bits of micros
public boolean isLeapYear(int year)
year
-
private int daysSinceEpoch(int year)
year
- a year since 1958
private int dayOfYear(int year, int month, int day)
month
- the month of the year starting at zero for Januaryday
- the day of the month starting at zero for the 1st day
public java.util.Date getDate()
public java.lang.String toRawFields()
public static java.lang.String toRawFields(long packetTime)
public java.lang.String toString()
toString
in class java.lang.Object
private void calculate()
public int compareTo(PDSDate dateTime)
compareTo
in interface java.lang.Comparable<PDSDate>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |