public final class DateFormatterUtil
extends java.lang.Object
Date
to a readable string representation or to convert a formatted
string to a Calendar
representation.Modifier and Type | Method and Description |
---|---|
static java.lang.String |
format(android.content.Context context,
java.util.Date date)
Converts
Date to a short string representation using abbreviations. |
static java.lang.String |
format(java.util.Date date)
Converts
Date to a string representation using DateFormat.SHORT and the
default locale of device. |
static java.util.Calendar |
format(java.lang.String dateString)
Converts the given string of format
dd-MM-yyyy HH:mm:ss to Calendar . |
public static java.util.Calendar format(java.lang.String dateString)
dd-MM-yyyy HH:mm:ss
to Calendar
.dateString
- source string to be converted to Calendar
.Calendar
or null
when source string could not be parsed.public static java.lang.String format(java.util.Date date)
Date
to a string representation using DateFormat.SHORT
and the
default locale of device.date
- the Date
to be converted to string representation.public static java.lang.String format(android.content.Context context, java.util.Date date)
Date
to a short string representation using abbreviations.
In general, times are abbreviated by not showing the minutes if they are 0. For example, instead of "3:00pm" the time would be abbreviated to "3pm". If date is not today, month is shown as a 3-letter string.
context
- the required context.date
- the Date
to be converted to string representation.