org.mbari.siam.utils
Class AsciiTime

java.lang.Object
  extended by org.mbari.siam.utils.AsciiTime

public class AsciiTime
extends java.lang.Object

A utility for acquiring the formatted date and time by passing a simple format string. There are two forms of getDate() and getTime(). One returns UTC time and date by default, the other is timezone selectable.


Field Summary
protected static int _date
           
protected static int _day
           
protected static int _hour12
           
protected static int _hour24
           
protected static int _minute
           
protected static int _month
           
protected static int _second
           
protected static int _year
           
 
Method Summary
static java.lang.String getDate(long time, java.lang.String formatString)
          Get specified date using specified format string and default timezone (UTC)
static java.lang.String getDate(long time, java.lang.String formatString, java.lang.String timeZone)
          Formats the specified time as a date string using the given format specifier and timezone
static java.lang.String getDate(java.lang.String formatString)
          Method returning the current date in Ascii format
static java.lang.String getDate(java.lang.String formatString, java.lang.String timeZone)
          Gets current time in specified format and timezone
static java.lang.String getTime(long time, java.lang.String formatString)
          Get specified time in specified format and default timezone (UTC)
static java.lang.String getTime(long time, java.lang.String formatString, java.lang.String timeZone)
          Formats the specified time as a time string using the given format specifier and timezone
static java.lang.String getTime(java.lang.String formatString)
          Method returning the current time in Ascii format
static java.lang.String getTime(java.lang.String formatString, java.lang.String timeZone)
          Get current time in specified format and time zone
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_month

protected static int _month

_date

protected static int _date

_year

protected static int _year

_day

protected static int _day

_hour24

protected static int _hour24

_hour12

protected static int _hour12

_minute

protected static int _minute

_second

protected static int _second
Method Detail

getTime

public static java.lang.String getTime(java.lang.String formatString)
Method returning the current time in Ascii format

Parameters:
formatString - String representing the required time format:- HH is substituted w/ current hour using 24 clock hh is substituted w/ current hour using 12 clock mm is substituted w/ minutes past the hour ss is substituted w/ seconds past the hour
Returns:
formatted time string Example - A format string "HH:mm:ss" would return the string "23:59:59" if current time is one second before midnight

getTime

public static java.lang.String getTime(java.lang.String formatString,
                                       java.lang.String timeZone)
Get current time in specified format and time zone


getTime

public static java.lang.String getTime(long time,
                                       java.lang.String formatString)
Get specified time in specified format and default timezone (UTC)


getTime

public static java.lang.String getTime(long time,
                                       java.lang.String formatString,
                                       java.lang.String timeZone)
Formats the specified time as a time string using the given format specifier and timezone


getDate

public static java.lang.String getDate(java.lang.String formatString)
Method returning the current date in Ascii format

Parameters:
formatString - String representing the required date format:- MM is substituted w/ current month DD is substituted w/ current day of month YY or YYYY is substituted w/ current year ddd is substituted w/ current day of year
Returns:
Formatted date string Example - A format string "MM/DD/YY" would return a date string "09/15/03". A format string "DD/MM/YYYY" would return the string "15/09/2003"

getDate

public static java.lang.String getDate(java.lang.String formatString,
                                       java.lang.String timeZone)
Gets current time in specified format and timezone


getDate

public static java.lang.String getDate(long time,
                                       java.lang.String formatString)
Get specified date using specified format string and default timezone (UTC)


getDate

public static java.lang.String getDate(long time,
                                       java.lang.String formatString,
                                       java.lang.String timeZone)
Formats the specified time as a date string using the given format specifier and timezone


main

public static void main(java.lang.String[] args)


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.