public class DateUtil extends Object
| Constructor and Description |
|---|
DateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
formatDate(Date date)
Formats the supplied date relative to the current time: Today, Yesterday, MMM dd, and
finally MMM dd, YYYY.
|
static String |
formatDate(Date date,
boolean useShorthand)
Formats the supplied date relative to the current time: Today, Yesterday, MMM dd, and
finally MMM dd, YYYY.
|
static String |
formatDateTime(Date date)
Creates a label of the form "
formatDate(java.util.Date) at formatTime(java.util.Date)". |
static String |
formatTime(Date date)
Creates a label of the form "9:15am".
|
static int |
getDayOfMonth(Date date) |
static int |
getDayOfWeek(Date date) |
static int |
getHour(Date date) |
static int |
getMinute(Date date) |
static int |
getMonth(Date date) |
static int |
getYear(Date date)
Returns the year component of the supplied date.
|
static Date |
newDate(String dateStr) |
static Date |
toDate(int[] datevec) |
static int[] |
toDateVec(Date date) |
static Date |
toUtc(Date date)
Returns the equivalent of this date when it was in Greenwich.
|
static void |
zeroTime(Date date) |
public static String formatTime(Date date)
public static String formatDate(Date date)
public static String formatDate(Date date, boolean useShorthand)
useShorthand - if false, "Today" and "Yesterday" will not be used, only the month/day
and month/day/year formats.public static String formatDateTime(Date date)
formatDate(java.util.Date) at formatTime(java.util.Date)". If date is null
the empty string is returned.public static Date toDate(int[] datevec)
public static int[] toDateVec(Date date)
public static int getDayOfMonth(Date date)
public static int getDayOfWeek(Date date)
public static int getMonth(Date date)
public static int getHour(Date date)
public static int getMinute(Date date)
public static int getYear(Date date)
Date.getYear() method returns. It's the actual
year. Returning years since 1900 is stupid.public static void zeroTime(Date date)
public static Date toUtc(Date date)
Copyright © 2013. All Rights Reserved.