jSyncManager

org.jSyncManager.API.Protocol.Util
Class DLP_Date

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.Util.DLP_Date
All Implemented Interfaces:
java.io.Serializable

public class DLP_Date
extends java.lang.Object
implements java.io.Serializable

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

Version:
$Revision: 1.7 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/05/14 03:51:27 $.
See Also:
Serialized Form

Constructor Summary
DLP_Date()
          Creates a new DLP date object using the current date and time.
DLP_Date(byte[] data)
          Create a new DLP date object with the specified DLP formatted date bytes.
DLP_Date(java.util.Calendar calendar)
          Create a new DLP date object using the specified date and time
 
Method Summary
static char calendar2DateType(java.util.Calendar calendar)
          Converts the provided Calendar object to a DLP two-byte Date representation.
 byte[] convertToBytes()
          Convert this date/time object to a series of DLP date/time bytes.
 java.util.Calendar convertToCalendar()
          Converts this date object to a Calendar object.
 int convertToSeconds()
          Convert this date object to the number of seconds since Jan 1st, 1904 @ 0000.
static java.util.Calendar dateType2Calendar(byte[] data, int i)
          Convert the provided date byte array into a Calendar object.
(package private) static java.util.Calendar seconds2Calendar(int i)
          Convert a value representing seconds since Jan 1st 1904 @ 0000 to a Calendar object.
 java.lang.String toString()
          Retreive this object as human-readable text.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DLP_Date

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

DLP_Date

public DLP_Date(java.util.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(byte[] data)
         throws InvalidDLPDateException
Create a new DLP date object with the specified DLP formatted date bytes.
Parameters:
data - the date and time data you want to set this date object to.
Throws:
InvalidDLPDateException - thrown if the provided data contains invalid information, or is null.
Method Detail

calendar2DateType

public static char calendar2DateType(java.util.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.

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 java.util.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 int 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 java.util.Calendar dateType2Calendar(byte[] data,
                                                   int i)
Convert the provided date byte array into a Calendar object.
Parameters:
data - an array containing DLP date information.
i - the offset into the array where the date information starts.
Returns:
the provided date byte array as a Calendar object.

seconds2Calendar

static java.util.Calendar seconds2Calendar(int 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 java.lang.String toString()
Retreive this object as human-readable text.
Overrides:
toString in class java.lang.Object
Returns:
this object as human-readable text.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.