org.archive.wayback.util
Class Timestamp

java.lang.Object
  extended by org.archive.wayback.util.Timestamp

public class Timestamp
extends Object

Represents a moment in time as a 14-digit string, and interally as a Date.

Version:
$Date: 2010-09-29 05:28:38 +0700 (Wed, 29 Sep 2010) $, $Revision: 3262 $
Author:
Brad Tofel

Constructor Summary
Timestamp()
          Constructor
Timestamp(Date date)
          Construct and initialize structure from an Date
Timestamp(int sse)
          Construct and initialize structure from an integer number of seconds since the epoch.
Timestamp(String dateStr)
          Construct and initialize structure from a 14-digit String timestamp.
 
Method Summary
 int absDistanceFromTimestamp(Timestamp otherTimeStamp)
          function that calculates integer seconds between this records timeStamp and the arguments timeStamp.
static Timestamp currentTimestamp()
           
static Calendar dateStrToCalendar(String dateStr)
          cleanup the dateStr argument assuming earliest values, and return a GMT calendar set to the time described by the dateStr.
 int distanceFromTimestamp(Timestamp otherTimeStamp)
          function that calculates integer seconds between this records timeStamp and the arguments timeStamp.
static Timestamp earliestTimestamp()
           
static Timestamp fromSse(int sse)
           
 Date getDate()
           
 String getDateStr()
           
 String getDay()
           
 String getMonth()
           
 String getYear()
           
static Timestamp latestTimestamp()
           
static String padEndDateStr(String timestamp)
          clean up timestamp argument assuming latest possible values for missing or bogus digits.
static String padStartDateStr(String timestamp)
          clean up timestamp argument assuming earliest possible values for missing or bogus digits.
static Timestamp parseAfter(String dateStr)
           
static Timestamp parseBefore(String dateStr)
           
 String prettyDate()
           
 String prettyDateTime()
           
 String prettyTime()
           
 void setDate(Date date)
          set internal structure using Date argument
 void setDateStr(String dateStr)
          initialize interal data structures for this Timestamp from the 14-digit argument.
 void setSse(int sse)
          set internal structure using seconds since the epoch integer argument
 int sse()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timestamp

public Timestamp()
Constructor


Timestamp

public Timestamp(String dateStr)
Construct and initialize structure from a 14-digit String timestamp. If the argument is too short, or specifies an invalid timestamp, cleanup will be attempted to create the earliest legal timestamp given the input.

Parameters:
dateStr -

Timestamp

public Timestamp(int sse)
Construct and initialize structure from an integer number of seconds since the epoch.

Parameters:
sse -

Timestamp

public Timestamp(Date date)
Construct and initialize structure from an Date

Parameters:
date -
Method Detail

setDate

public void setDate(Date date)
set internal structure using Date argument

Parameters:
date -

getDate

public Date getDate()
Returns:
Date for this Timestamp

setSse

public void setSse(int sse)
set internal structure using seconds since the epoch integer argument

Parameters:
sse -

setDateStr

public void setDateStr(String dateStr)
initialize interal data structures for this Timestamp from the 14-digit argument. Will clean up timestamp as needed to yield the ealiest possible timestamp given the possible partial or wrong argument.

Parameters:
dateStr -

getDateStr

public String getDateStr()
Returns:
the 14-digit String representation of this Timestamp.

sse

public int sse()
Returns:
the integer number of seconds since epoch represented by this Timestamp.

absDistanceFromTimestamp

public int absDistanceFromTimestamp(Timestamp otherTimeStamp)
function that calculates integer seconds between this records timeStamp and the arguments timeStamp. result is the absolute number of seconds difference.

Parameters:
otherTimeStamp -
Returns:
int absolute seconds between the argument and this records timestamp.

distanceFromTimestamp

public int distanceFromTimestamp(Timestamp otherTimeStamp)
function that calculates integer seconds between this records timeStamp and the arguments timeStamp. result is negative if this records timeStamp is less than the argument, positive if it is greater, and 0 if the same.

Parameters:
otherTimeStamp -
Returns:
int milliseconds

getYear

public String getYear()
Returns:
the year portion(first 4 digits) of this Timestamp

getMonth

public String getMonth()
Returns:
the month portion(digits 5-6) of this Timestamp

getDay

public String getDay()
Returns:
the day portion(digits 7-8) of this Timestamp

prettyDate

public String prettyDate()
Returns:
user friendly String representation of the date of this Timestamp. eg: "Jan 13, 1999"

prettyTime

public String prettyTime()
Returns:
user friendly String representation of the Time of this Timestamp.

prettyDateTime

public String prettyDateTime()
Returns:
user friendly String representation of the Date and Time of this Timestamp.

dateStrToCalendar

public static Calendar dateStrToCalendar(String dateStr)
cleanup the dateStr argument assuming earliest values, and return a GMT calendar set to the time described by the dateStr.

Parameters:
dateStr -
Returns:
Calendar

padEndDateStr

public static String padEndDateStr(String timestamp)
clean up timestamp argument assuming latest possible values for missing or bogus digits.

Parameters:
timestamp - String
Returns:
String

padStartDateStr

public static String padStartDateStr(String timestamp)
clean up timestamp argument assuming earliest possible values for missing or bogus digits.

Parameters:
timestamp - String
Returns:
String

parseBefore

public static Timestamp parseBefore(String dateStr)
Parameters:
dateStr -
Returns:
Timestamp object representing the earliest date represented by the (possibly) partial digit-string argument.

parseAfter

public static Timestamp parseAfter(String dateStr)
Parameters:
dateStr -
Returns:
Timestamp object representing the latest date represented by the (possibly) partial digit-string argument.

fromSse

public static Timestamp fromSse(int sse)
Parameters:
sse -
Returns:
Timestamp object representing the seconds since epoch argument.

currentTimestamp

public static Timestamp currentTimestamp()
Returns:
Timestamp object representing the current date.

latestTimestamp

public static Timestamp latestTimestamp()
Returns:
Timestamp object representing the latest possible date.

earliestTimestamp

public static Timestamp earliestTimestamp()
Returns:
Timestamp object representing the earliest possible date.


Copyright © 2005-2011 Internet Archive. All Rights Reserved.