org.gcube.accounting.common.helper
Class TimeHelper

java.lang.Object
  extended by org.gcube.accounting.common.helper.TimeHelper

public class TimeHelper
extends Object


Constructor Summary
TimeHelper()
           
 
Method Summary
static String format(Calendar c, boolean time)
          Return a human-readable representation of the given calendar.
static Calendar getCalendar(long timestamp)
          Computes a Calendar for the given timestamp
static Calendar getCalendar(String timestamp)
           
static Calendar getEnd(int year, int week)
          Compute the calendar object corresponding to the end of the week of the given year
static String getHumanReadableTime(long seconds)
          Produce a human-readable representation of the given timestamp.
static String getISO8601(long seconds)
          Compute a ISO9601 representation of the given timestamp
static Calendar getMonthEnd(int year, int month)
           
static Calendar getMonthStart(int year, int month)
           
static Calendar getStart(int year, int week)
          Compute the calendar object corresponding to the start of the week of the given year
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeHelper

public TimeHelper()
Method Detail

getStart

public static Calendar getStart(int year,
                                int week)
Compute the calendar object corresponding to the start of the week of the given year

Parameters:
year -
week -
Returns:

getMonthStart

public static Calendar getMonthStart(int year,
                                     int month)

getEnd

public static Calendar getEnd(int year,
                              int week)
Compute the calendar object corresponding to the end of the week of the given year

Parameters:
year -
week -
Returns:

getMonthEnd

public static Calendar getMonthEnd(int year,
                                   int month)

format

public static String format(Calendar c,
                            boolean time)
Return a human-readable representation of the given calendar.

Parameters:
c - the calendar object to format
time - whether you want HH:MM:SS information as well
Returns:
the string representation for the calendar object

getCalendar

public static Calendar getCalendar(long timestamp)
Computes a Calendar for the given timestamp

Parameters:
timestamp -
Returns:

getCalendar

public static Calendar getCalendar(String timestamp)
                            throws NumberFormatException
Throws:
NumberFormatException

getHumanReadableTime

public static String getHumanReadableTime(long seconds)
Produce a human-readable representation of the given timestamp. Output is of the form: "5 days, 4 hours, 8 minutes, 12 seconds"

Parameters:
seconds -
Returns:

getISO8601

public static String getISO8601(long seconds)
Compute a ISO9601 representation of the given timestamp

Parameters:
seconds -
Returns:


Copyright © 2013. All Rights Reserved.