com.sap.ip.me.api.services
Class DateFormatter

java.lang.Object
  extended bycom.sap.ip.me.api.services.DateFormatter

public class DateFormatter
extends java.lang.Object

Formats dates.

Author:
SAP

Constructor Summary
DateFormatter()
           
 
Method Summary
static java.lang.String getCurrentDate()
          Returns a date string for the current date in the format "yyyy-MM-dd".
static java.lang.String getCurrentDateABAP()
          Returns a date string for the current date in the ABAP format "yyyyMMdd".
static java.lang.String getCurrentTimeABAP()
          Returns a time string for the current date in the ABAP format "HHmmSS".
static java.lang.String getDate(java.util.Date date)
          Returns a date string for the given date object in the format "yyyy-MM-dd".
static java.util.Date getDate(java.lang.String date)
          Parses the given date string (yyyy-MM-dd) and returns a corresponding Date object.
static java.lang.String getDateABAP(java.util.Date date)
          Returns a date-time string for the given date object in the format "yyyyMMdd".
static java.lang.String getDateTime(java.util.Calendar c)
          Returns a date string for the given calendar object in the ABAP format "yyyy-MM-dd.HH.mm.ss.SSS".
static java.lang.String getDateTime(java.util.Date date)
          Returns a date string for the given date object in the ABAP format "yyyy-MM-dd.HH.mm.ss.SSS".
static java.lang.String getDateTime(java.lang.String date, java.lang.String time)
          Returns a date string for the given calendar object in the ABAP format "yyyy-MM-dd.HH.mm.ss.SSS".
static java.lang.String getTimeABAP(java.util.Date date)
          Returns a time string for the given date object in the ABAP format "HHmmSS".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormatter

public DateFormatter()
Method Detail

getDate

public static java.util.Date getDate(java.lang.String date)
                              throws java.text.ParseException
Parses the given date string (yyyy-MM-dd) and returns a corresponding Date object. If the date string cannot be parsed a ParseException will be thrown.

Parameters:
date - The date string that should be parsed. It has to be in the format "yyyy-MM-dd".
Returns:
A date object that corresponds to the date string.
Throws:
java.text.ParseException - If parsing fails a ParseException will be thrown.

getDate

public static java.lang.String getDate(java.util.Date date)
Returns a date string for the given date object in the format "yyyy-MM-dd".

Parameters:
date - The date object that should be formatted.
Returns:
A string that corresponds to the date object in the format "yyyy-MM-dd".

getCurrentDate

public static java.lang.String getCurrentDate()
Returns a date string for the current date in the format "yyyy-MM-dd".

Returns:
A string that corresponds to the current date in the format "yyyy-MM-dd".

getDateTime

public static java.lang.String getDateTime(java.util.Date date)
Returns a date string for the given date object in the ABAP format "yyyy-MM-dd.HH.mm.ss.SSS".

Parameters:
date - The date object that should be formatted
Returns:
A string that corresponds to the date object in the format "yyyy-MM-dd.HH.mm.ss.SSS".

getDateTime

public static java.lang.String getDateTime(java.util.Calendar c)
Returns a date string for the given calendar object in the ABAP format "yyyy-MM-dd.HH.mm.ss.SSS".

Returns:
A string that corresponds to the calendar object in the format "yyyy-MM-dd.HH.mm.ss.SSS".

getDateTime

public static java.lang.String getDateTime(java.lang.String date,
                                           java.lang.String time)
Returns a date string for the given calendar object in the ABAP format "yyyy-MM-dd.HH.mm.ss.SSS".

Returns:
A string that corresponds to the calendar object in the format "yyyy-MM-dd.HH.mm.ss.SSS".

getDateABAP

public static java.lang.String getDateABAP(java.util.Date date)
Returns a date-time string for the given date object in the format "yyyyMMdd".

Parameters:
date - The date object that should be formatted
Returns:
A string that corresponds to the date object in the format "yyyyMMdd".

getCurrentDateABAP

public static java.lang.String getCurrentDateABAP()
Returns a date string for the current date in the ABAP format "yyyyMMdd".

Returns:
A string that corresponds to the current date in the format "yyyyMMdd".

getTimeABAP

public static java.lang.String getTimeABAP(java.util.Date date)
Returns a time string for the given date object in the ABAP format "HHmmSS".

Parameters:
date - The date object that should be formatted
Returns:
A string that corresponds to the date object in the format "HHmmSS".

getCurrentTimeABAP

public static java.lang.String getCurrentTimeABAP()
Returns a time string for the current date in the ABAP format "HHmmSS".

Returns:
A string that corresponds to the current date in the format "HHmmSS".


Copyright © 2005 SAP AG. All Rights Reserved.