be.ehealth.technicalconnector.utils
Class DateUtils

java.lang.Object
  extended by be.ehealth.technicalconnector.utils.DateUtils

public final class DateUtils
extends Object

Utility class to work with dates


Method Summary
static org.joda.time.DateTime convert(Calendar cal)
          Converts an java.util.Calendar to an org.joda.DateTime
static org.joda.time.DateTime convert(Date date)
          Converts an java.util.Date to an org.joda.DateTime
static org.joda.time.DateTime parseDate(String text)
          Parses a date from the given text, returning a new DateTime.
static org.joda.time.DateTime parseDateTime(String text)
          Parses a datetime from the given text, returning a new DateTime.
static org.joda.time.DateTime parseTime(String text)
          Parses a time from the given text, returning a new DateTime.
static String printDate(org.joda.time.DateTime dateTime)
          Parses the dateTime, returning a string.
static String printDateTime(org.joda.time.DateTime dateTime)
          Combines the date and time by using the following format: yyyy-MM-dd'T'HH:mm:ss.SSSZZ
static String printTime(org.joda.time.DateTime dateTime)
          Gives the time by using the following format: HH:mm:ss.SSSZZ
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseDateTime

public static org.joda.time.DateTime parseDateTime(String text)
Parses a datetime from the given text, returning a new DateTime. (ISO8601 standard)

The parse will use the zone and chronology specified on this formatter.

If the text contains a time zone string then that will be taken into account in adjusting the time of day as follows. The the resulting DateTime will have the zone of this formatter, but the parsed zone may have caused the time to be adjusted.

 datetime          = time | date-opt-time 
 time              = 'T' time-element [offset]
 date-opt-time     = date-element ['T' [time-element] [offset]]
 date-element      = std-date-element | ord-date-element | week-date-element
 std-date-element  = yyyy ['-' MM ['-' dd]]
 ord-date-element  = yyyy ['-' DDD]
 week-date-element = xxxx '-W' ww ['-' e]
 time-element      = HH [minute-element] | [fraction]
 minute-element    = ':' mm [second-element] | [fraction]
 second-element    = ':' ss [fraction]
 fraction          = ('.' | ',') digit+
 offset            = 'Z' | (('+' | '-') HH [':' mm [':' ss [('.' | ',') SSS]]])
 
for example: 2012-10-15T05:38:14.030+02:00

Parameters:
text -
Returns:
the new DateTime

printDateTime

public static String printDateTime(org.joda.time.DateTime dateTime)
Combines the date and time by using the following format: yyyy-MM-dd'T'HH:mm:ss.SSSZZ

Parameters:
dateTime -
Returns:
the string value

parseTime

public static org.joda.time.DateTime parseTime(String text)
Parses a time from the given text, returning a new DateTime. (ISO8601 standard)

The parse will use the zone and chronology specified on this formatter.

If the text contains a time zone string then that will be taken into account in adjusting the time of day as follows. The the resulting DateTime will have the zone of this formatter, but the parsed zone may have caused the time to be adjusted.

 time           = ['T'] time-element [offset]
 time-element   = HH [minute-element] | [fraction]
 minute-element = ':' mm [second-element] | [fraction]
 second-element = ':' ss [fraction]
 fraction       = ('.' | ',') digit+
 offset         = 'Z' | (('+' | '-') HH [':' mm [':' ss [('.' | ',') SSS]]])
 

Parameters:
text -
Returns:
the new DateTime

printTime

public static String printTime(org.joda.time.DateTime dateTime)
Gives the time by using the following format: HH:mm:ss.SSSZZ

Parameters:
dateTime -
Returns:
the string value

parseDate

public static org.joda.time.DateTime parseDate(String text)
Parses a date from the given text, returning a new DateTime. (ISO8601 standard)

The parse will use the zone and chronology specified on this formatter.

If the text contains a time zone string then that will be taken into account in adjusting the time of day as follows. The the resulting DateTime will have the zone of this formatter, but the parsed zone may have caused the time to be adjusted.

 date              = date-element ['T' offset]
 date-element      = std-date-element | ord-date-element | week-date-element
 std-date-element  = yyyy ['-' MM ['-' dd]]
 ord-date-element  = yyyy ['-' DDD]
 week-date-element = xxxx '-W' ww ['-' e]
 offset            = 'Z' | (('+' | '-') HH [':' mm [':' ss [('.' | ',') SSS]]])
 

Parameters:
text -
Returns:
the new DateTime

printDate

public static String printDate(org.joda.time.DateTime dateTime)
Parses the dateTime, returning a string. (ISO8601 standard)

The parse will use the zone and chronology specified on this formatter.

Parameters:
dateTime -
Returns:
the string value

convert

public static org.joda.time.DateTime convert(Calendar cal)
Converts an java.util.Calendar to an org.joda.DateTime

Parameters:
cal -
Returns:
the new DateTime

convert

public static org.joda.time.DateTime convert(Date date)
Converts an java.util.Date to an org.joda.DateTime

Parameters:
date - the date
Returns:
the DateTime



Connector Packaging PERSDIETICIAN 3.11.1 API
Copyright © {inceptionYear}-2016 eHealth. All Rights Reserved.