public class FormatUtil extends Object
java.text
formatters, using a pool of thread-local instances. This avoids the cost of
constructing these objects on an as-needed basis (a tenth of a millisecond
or so, but it adds up), and also avoids the risk of using a single object
multiple threads.Constructor and Description |
---|
FormatUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
formatDate(Calendar cal,
String format)
Formats the date held in a
Calendar using the current
locale's timezone (not the calendar's own timezone). |
static String |
formatDate(Calendar cal,
String format,
String zoneId)
Formats the date held in a
Calendar using the specified
timezone (not the calendar's own timezone). |
static String |
formatDate(Date date,
String format)
Formats a date using a
SimpleDateFormat instance with the
current locale's timezone. |
static String |
formatDate(Date date,
String format,
String zoneId)
Formats a date using a
SimpleDateFormat instance with the
specified timezone. |
static String |
formatDate(long time,
String format)
Formats a Java timestamp (millis since epoch) using the current
locale's timezone.
|
static String |
formatDate(long time,
String format,
String zoneId)
Formats a Java timestamp (millis since epoch) using the specified
timezone (not the calendar's own timezone).
|
static String |
formatNumber(Number value,
String format)
Formats an arbitrary numeric object according to the current locale.
|
public static String formatDate(Date date, String format)
SimpleDateFormat
instance with the
current locale's timezone.public static String formatDate(Date date, String format, String zoneId)
SimpleDateFormat
instance with the
specified timezone.public static String formatDate(Calendar cal, String format)
Calendar
using the current
locale's timezone (not the calendar's own timezone).public static String formatDate(Calendar cal, String format, String zoneId)
Calendar
using the specified
timezone (not the calendar's own timezone).public static String formatDate(long time, String format)
public static String formatDate(long time, String format, String zoneId)