ie.omk.smpp.util
Class SMPPDate

java.lang.Object
  extended by ie.omk.smpp.util.SMPPDate
All Implemented Interfaces:
Serializable

public class SMPPDate
extends Object
implements Serializable

Object to represent a Date in SMPP format. SMPP dates take on a string form of 'YYMMDDhhmmsstnnp' where

indicates it is behind UTC and R indicates the time specification is relative to current SMSC time.

See Also:
Serialized Form

Constructor Summary
SMPPDate()
          Create a new SMPPDate.
SMPPDate(Calendar cal)
          Create a new SMPPDate representing an absolute time.
SMPPDate(Date d)
          Create a new SMPPDate representing an absolute time.
SMPPDate(int years, int months, int days, int hours, int minutes, int seconds)
          Create a new SMPPDate representing a relative time.
 
Method Summary
 boolean equals(Object obj)
          Check for equality against another SMPPDate object.
 Calendar getCalendar()
          Get a calendar object representing the internal time of this SMPPDate.
 int getDay()
          Get the day, or number of days in a relative time spec.
 int getHour()
          Get the hour, or number of hours in a relative time spec.
 int getMinute()
          Get the minute, or number of minutes in a relative time spec.
 int getMonth()
          Get the month, or number of months in a relative time spec.
 int getSecond()
          Get the second, or number of seconds in a relative time spec.
 char getSign()
          Get the UTC offset qualifier.
 int getTenth()
          Get the tenths of a second.
 TimeZone getTimeZone()
          Get the timezone that this date is in.
 int getUtcOffset()
          Get the number of quarter-hours from UTC the time spec is offset by.
 int getYear()
          Get the year, or number of years in a relative time spec.
 int hashCode()
          Get a hashCode for this object.
 boolean hasTimezone()
          Test if this SMPPDate has timezone information associated with it.
 boolean isRelative()
          Test if this SMPPDate represents a relative time specification.
static SMPPDate parseSMPPDate(String s)
          Parse an SMPP date string.
 String toString()
          Make an SMPP protocol string representing this Date object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SMPPDate

public SMPPDate()
Create a new SMPPDate. All fields will be initialised to zero.


SMPPDate

public SMPPDate(Date d)
Create a new SMPPDate representing an absolute time. The timezone offset will be set according to the current default timezone (as determined by the JVM).

Parameters:
d - The Date value to intialise this object to.
Throws:
NullPointerException - if d is null.

SMPPDate

public SMPPDate(Calendar cal)
Create a new SMPPDate representing an absolute time.

Throws:
NullPointerException - if cal is null.

SMPPDate

public SMPPDate(int years,
                int months,
                int days,
                int hours,
                int minutes,
                int seconds)
Create a new SMPPDate representing a relative time.

Method Detail

getCalendar

public Calendar getCalendar()
Get a calendar object representing the internal time of this SMPPDate. This method should not be used to retrieve a calendar from relative time specifications. That is, if this.isRelative() == true, you should not attempt to use the object returned from this method.


getYear

public int getYear()
Get the year, or number of years in a relative time spec.


getMonth

public int getMonth()
Get the month, or number of months in a relative time spec. January is month 1.


getDay

public int getDay()
Get the day, or number of days in a relative time spec. Day is in the range [1..31]


getHour

public int getHour()
Get the hour, or number of hours in a relative time spec. Hour is in the range [00..23]


getMinute

public int getMinute()
Get the minute, or number of minutes in a relative time spec. Minute is in the range [00..59]


getSecond

public int getSecond()
Get the second, or number of seconds in a relative time spec. Second is in the range [00..59]


getTenth

public int getTenth()
Get the tenths of a second. Always zero in a relative time spec. Tenths is in the range [0..9]


getUtcOffset

public int getUtcOffset()
Get the number of quarter-hours from UTC the time spec is offset by. This value is always positive. Use getSign() to determine if the time is ahead of or behind UTC. utcOffset is in the range [0..48]


getTimeZone

public TimeZone getTimeZone()
Get the timezone that this date is in. If this object represents a relative time definition, then this method will return null .

Returns:
The timezone of this SMPPDate.
See Also:
isRelative()

getSign

public char getSign()
Get the UTC offset qualifier. This flag is '+' to indicate that the time spec is ahead of UTC or '-' to indicate it is behind UTC. If the time spec is a relative time spec, this flag will be 'R'.

See Also:
getUtcOffset()

isRelative

public boolean isRelative()
Test if this SMPPDate represents a relative time specification.

Returns:
true is this object represents a relative time spec, false if it represents an absolute time spec.

hasTimezone

public boolean hasTimezone()
Test if this SMPPDate has timezone information associated with it. Relative time specs have no timezone information, neither does the short (12-character) form of the absolute time spec. The short-form absolute format should only be used by an SMSC - applications should never create a short-form format to send to the SMSC.

Returns:

equals

public boolean equals(Object obj)
Check for equality against another SMPPDate object.

Overrides:
equals in class Object

hashCode

public int hashCode()
Get a hashCode for this object.

Overrides:
hashCode in class Object

parseSMPPDate

public static SMPPDate parseSMPPDate(String s)
                              throws InvalidDateFormatException
Parse an SMPP date string. This method returns a handle to a newly created SMPPDate object with its fields initialised using the values in the SMPP-formatted date string s.

Returns:
a handle to this object.
Throws:
InvalidDateFormatException

toString

public String toString()
Make an SMPP protocol string representing this Date object.

Overrides:
toString in class Object
Returns:
The string representation as defined by the SMPP protocol.


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.