Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## spki
Class Date

    java.lang.Object
      |
      +--spki.BaseObj
            |
            +--spki.Date

public class Date
extends BaseObj

SPKI Date class.

Formal definition:

     <date>:: {ASCII-encoded <byte-string> of the form "YYYY-MM-DD_HH:MM:SS" in UTC time} ;

Version:
  $Id: Date.java,v 1.11 2002/05/15 23:05:08 tep Exp $
Author:
  Tep Narula <tep@win.trlabs.ca>, adapted from SPKI.SPKIValidBasic by Per Harald Myrvang <perm@pasta.cs.uit.no>

Field Summary
`private static String` | `__ME` This class's full name.
`private Date` | `date` This object's date value as a java.util.Date object.
`private String` | `date_string` This object's date value as a date-formated String.
`static String` | `MAX_DATE` The date +infinity (9999-12-31_11:59:59 GMT).
`static String` | `MIN_DATE` The date -infinity (0001-01-02_00:00:00 GMT).
`static String` | `SEXP_NAME` Date doesn't have an S-Expression type name since it's just a byte-string, so this field is initialized to `null`.
`private static SimpleDateFormat` | `spki_date` The date-format object used for parsing and formating String value of a date.

Fields inherited from class spki.BaseObj
`__ME, cache_sexp, cached_sexp, DEFAULT_HASH_ALG, locked, SEXP_NAME`

Constructor Summary
`Date()` Create an immutable Date object with the current time.
`Date(Date date)` Create an immutable Date object from a java.util.Date object.
`Date(SExpression sexp)` Create an immutable Date object from an S-Expression.
`Date(String date)` Create an immutable Date object from a date-formated String.

Method Summary
`(package private) static void` | `()` The static initializer for the date-format object.
`boolean` | `after(Date when)` Check if this is later than the given java.util.Date object.
`boolean` | `after(Date when)` Check if this is later than the given Date object.
`boolean` | `after(String when)` Check if this is later than the given date-formated String.
`boolean` | `before(Date when)` Check if this is earlier than the given java.util.Date object.
`boolean` | `before(Date when)` Check if this is earlier than the given Date object.
`boolean` | `before(String when)` Check if this is earlier than the given date-formated String.
`int` | `compareTo(Date when)` Compare this with the given java.util.Date object.
`int` | `compareTo(Date when)` Compare this with the given Date object.
`int` | `compareTo(String when)` Compare this with the given date-formated String.
`boolean` | `equals(Date when)` Check if this is equal to the given java.util.Date object.
`boolean` | `equals(Date when)` Check if this is equal to the given Date object.
`boolean` | `equals(String when)` Check if this is equal to the given date-formated String.
`Date` | `max(Date when)` Compare this with given date and return the later one.
`Date` | `min(Date when)` Compare this with given date and return the earlier one.
`Date` | `toJDate()` Get the java.util.Date object representing this object.
`SExpression` | `toSExpression()` Build an SExpression representing this object.
`String` | `toString()` Return this object as a string, or `null`.

Methods inherited from class spki.BaseObj
`disableSExpressionCaching, enableSExpressionCaching, extractHashAlgId, getCachedSExpression, isLocked, isSListOfType, lock, providerToSPKI, setCachedSExpression, spkiToProvider`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait`

Field Detail

### __ME

    private static final String __ME

  This class's full name.

### SEXP_NAME

    public static final String SEXP_NAME

  Date doesn't have an S-Expression type name since it's just a byte-string, so this field is initialized to `null`.

### spki_date

    private static SimpleDateFormat spki_date

  The date-format object used for parsing and formating String value of a date.
  See Also:
    `SimpleDateFormat`

### MAX_DATE

    public static final String MAX_DATE

  The date +infinity (9999-12-31_11:59:59 GMT). I deliberately substracted 12 hours off the actual maximum date (i.e. 9999-12-31_23:59:59) to make room for GMT+12 time zone.

### MIN_DATE

    public static final String MIN_DATE

  The date -infinity (0001-01-02_00:00:00 GMT). I deliberately added 24 hours to the actual minimum date (i.e. 0001-01-01_00:00:00) to make room for GMT-12 time zone. You may ask: why not 12 hours?. My answer is: "00:00:00" looks neater than "12:00:00" ;)

### date

    private Date date

  This object's date value as a java.util.Date object.
  See Also:
    `Date`

### date_string

    private String date_string

  This object's date value as a date-formated String.
  See Also:
    `spki_date`

Constructor Detail

### Date

    public Date()
         throws SPKIException

  Create an immutable Date object with the current time.

### Date

    public Date(SExpression sexp)
         throws ParseException,
                SPKIException

  Create an immutable Date object from an S-Expression.
  See Also:
    `BaseObj.BaseObj(SExpression)`

### Date

    public Date(Date date)
         throws SPKIException

  Create an immutable Date object from a java.util.Date object.
  Parameters:
    `date` - a java.util.Date object to build this object with.
  Throws:
    SPKIException - if some error occured during creation.

### Date

    public Date(String date)
         throws SPKIException

  Create an immutable Date object from a date-formated String.
  Parameters:
    `date` - a date-formated String to build this object with.
  Throws:
    SPKIException - if some error occured during creation.

Method Detail

###

    static void ()

  The static initializer for the date-format object. It initializes spki_date with the pattern "YYYY-MM-DD_HH:MM:SS" and set the time zone to UTC.
  See Also:
    `spki_date`

### toSExpression

    public SExpression toSExpression()
                              throws SPKIException

  Description copied from interface: SPKIObject
  Build an SExpression representing this object.
  Overrides:
    toSExpression in class BaseObj
  Tags copied from interface: SPKIObject
  Returns:
    SExpression object representing this object, or `null`.
  Throws:
    SPKIException - if something went wrong during conversion.

### toString

    public String toString()

  Return this object as a string, or `null`. It returns the cached date-formated string, which is faster and more efficient than calling this.toSExpression().toString().
  Overrides:
    toString in class BaseObj
  Tags copied from class: BaseObj
  Returns:
    SExpression list containing this object in Advanced form, or `null` if something went wrong.
  See Also:
    `BaseObj.toSExpression()`

### toJDate

    public Date toJDate()

  Get the java.util.Date object representing this object. It returns a clone of the cached java.util.Date object to prevent external tampering.
  Returns:
    a java.util.Date object.
  See Also:
    `Date`

### compareTo

    public int compareTo(Date when)

  Compare this with the given java.util.Date object.
  Parameters:
    `when` - the java.util.Date to compare with.
  Returns:
    `0` if the two dates are equal, `negative` integer if this date is earlier than given date, and `positive` integer if this date is later than given date.
  See Also:
    `Date.compareTo(java.util.Date)`

### compareTo

    public int compareTo(Date when)

  Compare this with the given Date object.
  Parameters:
    `when` - the Date to compare with.
  Returns:
    `0` if the two dates are equal, `negative` integer if this date is earlier than given date, and `positive` integer if this date is later than given date.
  See Also:
    `compareTo(java.util.Date)`

### compareTo

    public int compareTo(String when)
                  throws ParseException

  Compare this with the given date-formated String.
  Parameters:
    `when` - the date-formated String to compare with.
  Returns:
    `0` if the two dates are equal, `negative` integer if this date is earlier than given date, and `positive` integer if this date is later than given date.
  Throws:
    ParseException - if given String is not correctly formated.
  See Also:
    `compareTo(java.util.Date)`

### equals

    public boolean equals(Date when)

  Check if this is equal to the given java.util.Date object.
  Parameters:
    `when` - the java.util.Date to compare with.
  Returns:
    `true` if the two dates are equal, `false` otherwise.
  See Also:
    `Date.equals(Object)`

### equals

    public boolean equals(Date when)

  Check if this is equal to the given Date object.
  Parameters:
    `when` - the Date to compare with.
  Returns:
    `true` if the two dates are equal, `false` otherwise.
  See Also:
    `equals(java.util.Date)`

### equals

    public boolean equals(String when)
                   throws ParseException

  Check if this is equal to the given date-formated String.
  Parameters:
    `when` - the date-formated String to compare with.
  Returns:
    `true` if the two dates are equal, `false` otherwise.
  Throws:
    ParseException - if given String is not correctly formated.
  See Also:
    `equals(java.util.Date)`

### after

    public boolean after(Date when)

  Check if this is later than the given java.util.Date object.
  Parameters:
    `when` - the java.util.Date to compare with.
  Returns:
    `true` if this date is later, `false` otherwise.
  See Also:
    `Date.after(java.util.Date)`

### after

    public boolean after(Date when)

  Check if this is later than the given Date object.
  Parameters:
    `when` - the Date to compare with.
  Returns:
    `true` if this date is later, `false` otherwise.
  See Also:
    `after(java.util.Date)`

### after

    public boolean after(String when)
                  throws ParseException

  Check if this is later than the given date-formated String.
  Parameters:
    `when` - the date-formated String to compare with.
  Returns:
    `true` if this date is later, `false` otherwise.
  Throws:
    ParseException - if given String is not correctly formated.
  See Also:
    `after(java.util.Date)`

### before

    public boolean before(Date when)

  Check if this is earlier than the given java.util.Date object.
  Parameters:
    `when` - the java.util.Date to compare with.
  Returns:
    `true` if this date is earlier, `false` otherwise.
  See Also:
    `Date.before(java.util.Date)`

### before

    public boolean before(Date when)

  Check if this is earlier than the given Date object.
  Parameters:
    `when` - the Date to compare with.
  Returns:
    `true` if this date is earlier, `false` otherwise.
  See Also:
    `before(java.util.Date)`

### before

    public boolean before(String when)
                   throws ParseException

  Check if this is earlier than the given date-formated String.
  Parameters:
    `when` - the date-formated String to compare with.
  Returns:
    `true` if this date is earlier, `false` otherwise.
  Throws:
    ParseException - if given String is not correctly formated.
  See Also:
    `before(java.util.Date)`

### min

    public Date min(Date when)

  Compare this with given date and return the earlier one.
  Parameters:
    `when` - a Date object to compare with.
  Returns:
    the earlier date.

### max

    public Date max(Date when)

  Compare this with given date and return the later one.
  Parameters:
    `when` - a Date object to compare with.
  Returns:
    the later date.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD