public class DateFormat
extends java.lang.Object
Constructor and Description |
---|
DateFormat(java.lang.String format)
Creates a DateFormat instance based on the given format.
|
DateFormat(java.lang.String format,
java.lang.String locale)
Creates a DateFormat instance based on the given format and locale.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
format(java.util.Date date)
Formats the given Date to a String that complies with the defined format.
|
java.lang.String |
getLocale()
Get the locale that this
DateFormat Object is working in. |
int |
getTimeZoneOffset()
Get the current time zone for this
DateFormat . |
java.util.Date |
parse(java.lang.String dateString)
Tries to parse the given String into a valid Date Object.
|
void |
setTimeZoneOffset(int offsetInMins)
Sets current time zone offset in minutes relative to GMT.
|
public DateFormat(java.lang.String format)
format
- - format string, e.g. yyyy.MM.ddpublic DateFormat(java.lang.String format, java.lang.String locale)
format
- - format string, e.g. yyyy.MM.ddlocale
- - locale string, e.g. de_DEpublic java.lang.String format(java.util.Date date)
public java.util.Date parse(java.lang.String dateString) throws ParseException
dateString
- A String that should match date format patterndateString
.ParseException
- if the dateString
can't be parsed.public int getTimeZoneOffset()
DateFormat
.public void setTimeZoneOffset(int offsetInMins)
offsetInMins
- the offset, expressed as a number of whole minutes.public java.lang.String getLocale()
DateFormat
Object is working in.