下面列出了org.apache.commons.lang3.time.DateFormatUtils#formatUTC ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public String humanizeTimestamp(long timestamp) {
if (taskDatePattern.isPresent() && timeZone.isPresent()) {
return DateFormatUtils.format(timestamp, taskDatePattern.get(), timeZone.get());
} else if (taskDatePattern.isPresent()) {
return DateFormatUtils.formatUTC(timestamp, taskDatePattern.get());
} else if (timeZone.isPresent()) {
return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT, timeZone.get());
} else {
return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT);
}
}
/**
* @param date
*/
protected static String formatDate(Calendar date) {
return DateFormatUtils.formatUTC(date.getTimeInMillis(), "yyyy-MM-dd'T'HH:mm:ss'Z'"); //$NON-NLS-1$
}
/**
* @param date
*/
protected static String formatDateWithMillis(Calendar date) {
return DateFormatUtils.formatUTC(date.getTimeInMillis(), "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); //$NON-NLS-1$
}
/**
* 使用日期对象构造时间
* @param date
*/
public TimeUtils(Date date){
this(DateFormatUtils.formatUTC(date, "HH:mm:ss"));
}
/**
* Formats the given date so that it conforms with the WebDAV creation date/time format
*
* @param date The date to format
* @return The formatted date string
*/
public static String formatCreationDate(Date date)
{
return DateFormatUtils.formatUTC(date, CREATION_DATE_FORMAT);
}
/**
* Formats the given date so that it conforms with the WebDAV creation date/time format
*
* @param ldate long
* @return The formatted date string
*/
public static String formatCreationDate(long ldate)
{
return DateFormatUtils.formatUTC(ldate, CREATION_DATE_FORMAT);
}
/**
* 使用日期对象构造时间
* @param date
*/
public TimeUtils(Date date){
this(DateFormatUtils.formatUTC(date, "HH:mm:ss"));
}