org.jopendocument.util
Class TimeUtils

java.lang.Object
  extended by org.jopendocument.util.TimeUtils

public class TimeUtils
extends Object


Constructor Summary
TimeUtils()
           
 
Method Summary
static Calendar copyLocalTime(Calendar from, Calendar to)
          Copy the local time from one calendar to another.
static BigDecimal getSeconds(Duration d)
          Get non-null seconds with the the correct class.
static DatatypeFactory getTypeFactory()
           
static long normalizeLocalTime(Calendar cal)
          Normalize cal so that any Calendar with the same local time have the same result.
static Duration timePartToDuration(Calendar cal)
          Convert the time part of a calendar to a duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeUtils

public TimeUtils()
Method Detail

getTypeFactory

public static final DatatypeFactory getTypeFactory()

getSeconds

public static final BigDecimal getSeconds(Duration d)
Get non-null seconds with the the correct class.

Parameters:
d - a duration.
Returns:
the seconds, never null.
See Also:
Duration.getField(javax.xml.datatype.DatatypeConstants.Field), Duration.getMinutes()

timePartToDuration

public static final Duration timePartToDuration(Calendar cal)
Convert the time part of a calendar to a duration.

Parameters:
cal - a calendar, e.g. 23/12/2011 11:55:33.066 GMT+02.
Returns:
a duration, e.g. P0Y0M0DT11H55M33.066S.

normalizeLocalTime

public static final long normalizeLocalTime(Calendar cal)
Normalize cal so that any Calendar with the same local time have the same result. If you don't need a Calendar this is faster than copyLocalTime(Calendar, Calendar).

Parameters:
cal - a calendar, e.g. 0:00 CEST.
Returns:
the time in millisecond of the UTC calendar with the same local time, e.g. 0:00 UTC.

copyLocalTime

public static final Calendar copyLocalTime(Calendar from,
                                           Calendar to)
Copy the local time from one calendar to another. Except if both calendars have the same time zone, from.getTimeInMillis() will be different from to.getTimeInMillis().

Parameters:
from - the source calendar, e.g. 23/12/2011 11:55:33.066 GMT-12.
to - the destination calendar, e.g. 01/01/2000 0:00 GMT+13.
Returns:
the modified destination calendar, e.g. 23/12/2011 11:55:33.066 GMT+13.


Copyright © 2010 jOpenDocument All Rights Reserved.