org.jSyncManager.API.Protocol.Util

Class DLP_Date

Implemented Interfaces:
Serializable

public class DLP_Date
extends java.lang.Object
implements Serializable

A class to hold a Palm DLP protocol Date element. This class holds date information.

Field Summary

static long
JAN1_1904_MS_FROM_EPOCH
static char
VFS_CREATION_DATE
A value for use when calling get/setVFSFileDate in order to specify that you wish to request the files creation date.
static char
VFS_LAST_ACCESSED_DATE
A value for use when calling get/setVFSFileDate in order to specify that you wish to request the files last acccess date.
static char
VFS_MODIFICATION_DATE
A value for use when calling get/setVFSFileDate in order to specify that you wish to request the files modification date.

Constructor Summary

DLP_Date()
Creates a new DLP date object using the current date and time.
DLP_Date(Calendar calendar)
Create a new DLP date object using the specified date and time
DLP_Date(data[] )
Create a new DLP date object with the specified DLP formatted date bytes.

Method Summary

static char
calendar2DateType(Calendar calendar)
Converts the provided Calendar object to a DLP two-byte Date representation.
static long
calendar2Seconds(Calendar calendar)
Converts a calendar object to a long representing seconds since January 1st, 1904 @ 00:00.
byte[]
convertToBytes()
Convert this date/time object to a series of DLP date/time bytes.
Calendar
convertToCalendar()
Converts this date object to a Calendar object.
long
convertToSeconds()
Convert this date object to the number of seconds since Jan 1st, 1904 @ 0000.
static Calendar
dateType2Calendar(data[] , int i)
Convert the provided date byte array into a Calendar object.
static DLP_Date
emptyDate()
Creates a new empty DLP Date object.
static Calendar
seconds2Calendar(long i)
Convert a value representing seconds since Jan 1st 1904 @ 0000 to a Calendar object.
String
toString()
Retreive this object as human-readable text.

Field Details

JAN1_1904_MS_FROM_EPOCH

public static final long JAN1_1904_MS_FROM_EPOCH
Field Value:
-2082844800000L

VFS_CREATION_DATE

public static final char VFS_CREATION_DATE
A value for use when calling get/setVFSFileDate in order to specify that you wish to request the files creation date.
Field Value:
'\u0001'

VFS_LAST_ACCESSED_DATE

public static final char VFS_LAST_ACCESSED_DATE
A value for use when calling get/setVFSFileDate in order to specify that you wish to request the files last acccess date.
Field Value:
'\u0003'

VFS_MODIFICATION_DATE

public static final char VFS_MODIFICATION_DATE
A value for use when calling get/setVFSFileDate in order to specify that you wish to request the files modification date.
Field Value:
'\u0002'

Constructor Details

DLP_Date

public DLP_Date()
Creates a new DLP date object using the current date and time.

DLP_Date

public DLP_Date(Calendar calendar)
            throws InvalidDLPDateException
Create a new DLP date object using the specified date and time
Parameters:
calendar - the date and time you want to set this date object to.
Throws:
InvalidDLPDateException - thrown if the provided calendar contains invalid information, or is null.

DLP_Date

public DLP_Date(data[] )
            throws InvalidDLPDateException
Create a new DLP date object with the specified DLP formatted date bytes.
Parameters:
Throws:
InvalidDLPDateException - thrown if the provided data contains invalid information, or is null.

Method Details

calendar2DateType

public static char calendar2DateType(Calendar calendar)
Converts the provided Calendar object to a DLP two-byte Date representation.
Parameters:
calendar - the date to convert.
Returns:
a char representing the date portion of the provided calendar object.

calendar2Seconds

public static long calendar2Seconds(Calendar calendar)
Converts a calendar object to a long representing seconds since January 1st, 1904 @ 00:00.
Parameters:
calendar - a java.util.Calendar instance containing the time you want to convert.
Returns:
a long representing seconds since January 1st, 1904 @ 00:00.

convertToBytes

public byte[] convertToBytes()
Convert this date/time object to a series of DLP date/time bytes.
Returns:
a series of bytes representing this date object.

convertToCalendar

public Calendar convertToCalendar()
Converts this date object to a Calendar object. The current implementation will actually create a GregorianCalendar object, and will return it as a Calendar object.
Returns:
this date object represented as a Calendar object.

convertToSeconds

public long convertToSeconds()
Convert this date object to the number of seconds since Jan 1st, 1904 @ 0000.
Returns:
the number of seconds since Jan 1st, 1904 @ 0000.

dateType2Calendar

public static Calendar dateType2Calendar(data[] ,
                                         int i)
Convert the provided date byte array into a Calendar object.
Parameters:
i - the offset into the array where the date information starts.
Returns:
the provided date byte array as a Calendar object.

emptyDate

public static DLP_Date emptyDate()
Creates a new empty DLP Date object. This constructor will create a DLP date with year (and all other fields) set to 0.
Returns:
a new empty DLP Date object.

seconds2Calendar

public static Calendar seconds2Calendar(long i)
Convert a value representing seconds since Jan 1st 1904 @ 0000 to a Calendar object.
Parameters:
i - a value representing seconds since Jan 1st 1904 @ 0000.
Returns:
a Calendar object containing the date and time represented by the input.

toString

public String toString()
Retreive this object as human-readable text.
Returns:
this object as human-readable text.