|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jfw.util.DateUtils
public final class DateUtils
Date utils methods. All methods are static and thread safe.
Constructor Summary | |
---|---|
DateUtils()
|
Method Summary | |
---|---|
static int[] |
elapsed(java.util.GregorianCalendar g1,
java.util.GregorianCalendar g2)
Calculate the difference between to dates. |
static java.lang.String |
format(java.lang.String toChange)
Change a date String in format "yyyy-mm-dd" in format "dd/mm/yyyy". |
static java.lang.String |
format(java.lang.String toChange,
java.lang.String format)
Change a date String in format "dd/mm/yyyy" in format specified in parameter format. |
static java.lang.String |
format4DB(java.lang.String toChange)
Change a String from format "dd/mm/yyyy" to format "yyyymmdd". |
static java.lang.String |
formatAddLeadingZero(java.lang.String toChange)
Change a String from format "d/m/yyyy" adding leading zeros for day and month. |
static java.lang.String |
fromDateToString(java.util.Date date)
Change an java.util.Date in a String with format "dd-mm-yyyy". |
static java.lang.String |
fromDateToString(java.sql.Date date)
Change an java.sql.Date in a String with format "dd-mm-yyyy". |
static java.lang.String |
fromDateToString(java.util.Date date,
java.lang.String format)
Change an java.util.Date in a String with format the format specified in parameter format. |
static java.lang.String |
fromDateToString(java.sql.Date date,
java.lang.String format)
Change an java.util.Date in a String with format the format specified in parameter format. |
static java.lang.String |
getDateAndTime()
Return a string with the current date and time. |
static java.lang.String |
getDateString(java.util.GregorianCalendar gregorian)
Get a String in format "dd/mm/yyyy". |
static java.lang.String |
getDayFromDate(java.lang.String date)
Get day from a String in format "mm/dd/yyyy". |
static java.lang.String |
getDayFromDateUS(java.lang.String date)
Get day from a String in format "yyyy-mm-dd". |
static java.util.GregorianCalendar |
getGregorianCalendar()
Return the java.util.GregorianCalendar for time zone CET. |
static java.util.GregorianCalendar |
getGregorianCalendar(java.lang.String dateString)
Return the java.util.GregorianCalendar of the date specified in parameter dateString. |
static java.util.GregorianCalendar |
getGregorianCalendar(java.lang.String dateString,
java.lang.String separator)
Return the java.util.GregorianCalendar of the date specified in parameter dateString. |
static java.lang.String |
getHoursFromDateTime(java.lang.String dateTime)
Get hours from a String in format "date_in various_format mm:hh" |
static java.lang.String |
getMinutesFromDateTime(java.lang.String dateTime)
Get minutes from a String in format "date_in various_format mm:hh" |
static java.lang.String |
getMonth(java.util.GregorianCalendar gregorian)
Return the month of year as a String from 1 to 12. |
static java.lang.String |
getMonthDay(java.util.GregorianCalendar gregorian)
Return the day of month. |
static java.lang.String |
getMonthDay(java.util.GregorianCalendar gregorian,
boolean leadingZero)
Return the day of month adding a 0 at start if needed. |
static java.lang.String |
getMonthFromDate(java.lang.String date)
Get month from a String in format "mm/dd/yyyy". |
static java.lang.String |
getMonthFromDateUS(java.lang.String date)
Get month from a String in format "yyyy-mm-dd". |
static java.lang.String |
getMSecondsFromDateTime(java.lang.String dateTime)
Get mseconds from a String in format "date_in various_format mm:hh:ss.ms" |
static java.lang.String |
getSecondsFromDateTime(java.lang.String dateTime)
Get seconds from a String in format "date_in various_format mm:hh:ss" |
static java.lang.String |
getTimeExtension()
Get a string with format .YYYY-MM-DD.HH-MM-SS. |
static java.lang.String |
getTimeExtension(long date)
Get a string with format .YYYY-MM-DD.HH-MM-SS. |
static java.lang.String |
getWeekDay(java.util.GregorianCalendar gregorian)
Return the day of week. |
static java.lang.String |
getYear(java.util.GregorianCalendar gregorian)
Return the year. |
static java.lang.String |
getYearFromDate(java.lang.String date)
Get year from a String in format "mm/dd/yyyy". |
static java.lang.String |
getYearFromDateUS(java.lang.String date)
Get year from a String in format "yyyy-mm-dd". |
static java.lang.String[] |
transformDate(java.lang.String dateTime)
Get a formated string reppresentation of Date.getTime() string value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DateUtils()
Method Detail |
---|
public static java.lang.String fromDateToString(java.util.Date date)
date
- the java.util.Date to format
public static java.lang.String fromDateToString(java.sql.Date date)
date
- the java.sql.Date to format
public static java.lang.String fromDateToString(java.util.Date date, java.lang.String format)
date
- the java.util.Date to formatformat
- the format to use
public static java.lang.String fromDateToString(java.sql.Date date, java.lang.String format)
date
- the java.sql.Date to formatformat
- the format to use
public static java.lang.String format(java.lang.String toChange, java.lang.String format)
toChange
- the String to formatformat
- the format to use
public static java.lang.String format(java.lang.String toChange)
toChange
- the String to format
public static java.lang.String format4DB(java.lang.String toChange)
toChange
- Stringa in format "dd/mm/yyyy" to change
public static java.lang.String formatAddLeadingZero(java.lang.String toChange)
toChange
- Stringa in format "d/m/yyyy" to change
public static java.lang.String getDateString(java.util.GregorianCalendar gregorian)
gregorian
- the java.util.GregorianCalendar to use
public static java.util.GregorianCalendar getGregorianCalendar(java.lang.String dateString)
dateString
- String in format "dd/mm/yyyy".
public static java.util.GregorianCalendar getGregorianCalendar(java.lang.String dateString, java.lang.String separator)
dateString
- a String in format "dd$mm$yyyy"separator
- the separator for the dateString parameter ($)
public static java.util.GregorianCalendar getGregorianCalendar()
public static java.lang.String getMonthDay(java.util.GregorianCalendar gregorian)
gregorian
- java.util.GregorianCalendar object
public static java.lang.String getMonthDay(java.util.GregorianCalendar gregorian, boolean leadingZero)
gregorian
- java.util.GregorianCalendar objectleadingZero
- if true a leading zero add when need
public static java.lang.String getWeekDay(java.util.GregorianCalendar gregorian)
gregorian
- a java.util.GregorianCalendar object
public static java.lang.String getMonth(java.util.GregorianCalendar gregorian)
gregorian
- a java.util.GregorianCalendar object
public static java.lang.String getYear(java.util.GregorianCalendar gregorian)
gregorian
- a java.util.GregorianCalendar object
public static java.lang.String getDayFromDateUS(java.lang.String date)
date
- String in format "yyyy-mm-dd" to use
public static java.lang.String getMonthFromDateUS(java.lang.String date)
date
- String in format "yyyy-mm-dd" to use
public static java.lang.String getYearFromDateUS(java.lang.String date)
date
- String in format "yyyy-mm-dd" to use
public static java.lang.String getDayFromDate(java.lang.String date)
date
- String in format "mm/dd/yyyy" to use
public static java.lang.String getMonthFromDate(java.lang.String date)
date
- String in format "mm/dd/yyyy" to use
public static java.lang.String getYearFromDate(java.lang.String date)
date
- String in format "mm/dd/yyyy" to use
public static java.lang.String getHoursFromDateTime(java.lang.String dateTime)
dateTime
- String in format "date_in various_format mm:hh" to use
public static java.lang.String getMinutesFromDateTime(java.lang.String dateTime)
dateTime
- String in format "date_in various_format mm:hh" to use
public static java.lang.String getSecondsFromDateTime(java.lang.String dateTime)
dateTime
- String in format "date_in various_format mm:hh:ss" to use
public static java.lang.String getMSecondsFromDateTime(java.lang.String dateTime)
dateTime
- String in format "date_in various_format mm:hh:ss.ms" to use
public static int[] elapsed(java.util.GregorianCalendar g1, java.util.GregorianCalendar g2)
g1
- a java.util.GregorianCalendar object.g2
- a java.util.GregorianCalendar object.
public static final java.lang.String getTimeExtension()
public static final java.lang.String getTimeExtension(long date)
date
- a Date.getTime() value.
public static java.lang.String[] transformDate(java.lang.String dateTime)
dateTime
- string value of Date.getTime().
public static java.lang.String getDateAndTime()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |