Class DateUtil
java.lang.Object
org.jpos.util.DateUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormatsdusing the US short date / medium time format.static StringdateTimeToString(Date d, String tzString) Formatsdusing the US short date / medium time format in the given time zone.static StringFormatsdusing theMM/dd/yyyy HH:mm:sspattern.static StringdateToString(Date d) Formatsdusing the US short date format.static StringdateToString(Date d, String tzString) Formatsdusing the JVM default date format in the given time zone.static StringFormatsdusing theMM/dd/yyyypattern.static DateParsessusing the US short date format.static DateParsessusing theMM/dd/yypattern.static DateParsessusing theMM/dd/yyyypattern.static DateParsessusing theyyyyMMddpattern.static DateParsessusing the US short date / medium time format.static DateparseDateTime(String d, String t) Parses anMMDDYYdate andHHMMSStime, choosing the century closest to "now" so two-digit years near a century boundary round to the correct year.static DateParsessusing theMM/dd/yyyy HH:mm:sspattern.static DateparseDateTime_mmddyyyy(String s, String tzString) Parsessusing theMM/dd/yyyy HH:mm:sspattern in the given time zone.static DateParses anHHMMorHHMMSStime using today as the date.static DateParses anHHMMorHHMMSStime usingnowas the date portion.static DateParsessusing theMM/dd/yyyy HH:mm:sspattern.static StringFormatsdusing theMM/dd/yyyypattern.static StringFormatsdusing theMM/dd/yyyy HH:mm:sspattern.static StringtimeToString(Date d) Formats the time portion ofdusing the JVM short time format.static StringtimeToString(Date d, String tzString) Formats the time portion ofdusing the JVM short time format in the given time zone.static StringtoDays(long period) Renders a duration in milliseconds as a compact1h2m3s-style string.
-
Constructor Details
-
DateUtil
public DateUtil()Utility class; instances carry no state.
-
-
Method Details
-
parseDate
Parsessusing the US short date format.- Parameters:
s- date string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseDate_mmddyyyy
Parsessusing theMM/dd/yyyypattern.- Parameters:
s- date string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseDate_yyyymmdd
Parsessusing theyyyyMMddpattern.- Parameters:
s- date string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseDate_mmddyy
Parsessusing theMM/dd/yypattern.- Parameters:
s- date string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseDateTime
Parsessusing the US short date / medium time format.- Parameters:
s- date-time string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseDateTime_mmddyyyy
Parsessusing theMM/dd/yyyy HH:mm:sspattern.- Parameters:
s- date-time string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseTimestamp
Parsessusing theMM/dd/yyyy HH:mm:sspattern.- Parameters:
s- timestamp string, ornull- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
parseDateTime_mmddyyyy
Parsessusing theMM/dd/yyyy HH:mm:sspattern in the given time zone.- Parameters:
s- date-time string, ornulltzString- time-zone identifier accepted byTimeZone.getTimeZone(String);nullkeeps the JVM default zone- Returns:
- parsed date, or
nullwhensisnull - Throws:
ParseException- if the string cannot be parsed
-
dateToString
Formatsdusing the US short date format.- Parameters:
d- date, ornull- Returns:
- formatted string, or
nullwhendisnull
-
dateToString_mmddyyyy
Formatsdusing theMM/dd/yyyypattern.- Parameters:
d- date, ornull- Returns:
- formatted string, or
nullwhendisnull
-
dateTimeToString
Formatsdusing the US short date / medium time format.- Parameters:
d- date, ornull- Returns:
- formatted string, or
nullwhendisnull
-
dateTimeToString
Formatsdusing the US short date / medium time format in the given time zone.- Parameters:
d- date, ornulltzString- time-zone identifier;nullkeeps the JVM default zone- Returns:
- formatted string, or
nullwhendisnull
-
dateTimeToString_mmddyyyy
Formatsdusing theMM/dd/yyyy HH:mm:sspattern.- Parameters:
d- date, ornull- Returns:
- formatted string, or
nullwhendisnull
-
timestamp
-
postdate
-
parseDateTime
Parses anMMDDYYdate andHHMMSStime, choosing the century closest to "now" so two-digit years near a century boundary round to the correct year.- Parameters:
d- date inMMDDYYt- time inHHMMSS- Returns:
- parsed date
-
parseTime
-
parseTime
-
dateToString
Formatsdusing the JVM default date format in the given time zone.- Parameters:
d- datetzString- time-zone identifier;nullkeeps the JVM default zone- Returns:
- formatted date string
-
timeToString
Formats the time portion ofdusing the JVM short time format in the given time zone.- Parameters:
d- datetzString- time-zone identifier;nullkeeps the JVM default zone- Returns:
- formatted time string
-
timeToString
Formats the time portion ofdusing the JVM short time format.- Parameters:
d- date- Returns:
- formatted time string
-
toDays
-