Methods Summary |
---|
public static void | main(java.lang.String[] pArgs)
LogInit.init();
DateFormatExample example = new DateFormatExample();
example.testSimpleFormat();
example.testRoundedDates();
example.testTruncate();
example.testIterator();
example.testFormatUTC();
|
public void | testFormatUTC()
Date now = new Date();
logger.debug(
"now: "
+ DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now));
logger.debug(
"UTC Time: "
+ DateFormatUtils.formatUTC(
now,
DateFormatUtils
.ISO_DATETIME_TIME_ZONE_FORMAT
.getPattern()));
|
public void | testIterator()
Date now = new Date();
logger.debug(
"now: "
+ DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now));
Iterator iter = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY);
while (iter.hasNext()) {
Calendar cal = (Calendar) iter.next();
Date cur = cal.getTime();
logger.debug(
"iterate: "
+ DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(cur));
}
|
public void | testRoundedDates()
FastDateFormat sdf = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT;
Date now = new Date();
Date nearestHour = DateUtils.round(now, Calendar.HOUR);
Date nearestMonth = DateUtils.round(now, Calendar.MONTH);
Date nearestYear = DateUtils.round(now, Calendar.YEAR);
logger.debug("now: " + sdf.format(now));
logger.debug("round hour: " + sdf.format(nearestHour));
logger.debug("round month: " + sdf.format(nearestMonth));
logger.debug("round year: " + sdf.format(nearestYear));
|
public void | testSimpleFormat()
Date now = new Date();
logger.debug(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now));
|
public void | testTruncate()
Date now = new Date();
Date truncYear = DateUtils.truncate(now, Calendar.YEAR);
Date truncMonth = DateUtils.truncate(now, Calendar.MONTH);
logger.debug(
"now: "
+ DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now));
logger.debug(
"truncYear: "
+ DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(
truncYear));
logger.debug(
"truncMonth: "
+ DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(
truncMonth));
|