使用 DurationFormatUtils 计算时间间隔
2012-03-09 00:00
113 查看
// 当前时间
Date now = new Date();
// 2010上海世博会开幕时间
Date expo2010BeginDate = DateUtils.parseDate("2010-05-01 23:59:59", new String[] { "yyyy-MM-dd HH:mm:ss" });
// 2010上海世博会闭幕时间
Date expo2010EndDate = DateUtils.parseDate("2010-10-31 23:59:59", new String[] { "yyyy-MM-dd HH:mm:ss" });
System.out.println(DurationFormatUtils.formatDuration(expo2010BeginDate.getTime() - now.getTime(), "d"));
System.out.println(DurationFormatUtils.formatDuration(expo2010BeginDate.getTime() - expo2010EndDate.getTime(),
"d"));
Duration formatting utilities and constants. The following table describes the tokens used in the pattern language for formatting.
以下是format参数
$(document).ready(function(){dp.SyntaxHighlighter.HighlightAll('code');});
原文链接:
http://blog.csdn.net/kimsoft/article/details/5106984
Date now = new Date();
// 2010上海世博会开幕时间
Date expo2010BeginDate = DateUtils.parseDate("2010-05-01 23:59:59", new String[] { "yyyy-MM-dd HH:mm:ss" });
// 2010上海世博会闭幕时间
Date expo2010EndDate = DateUtils.parseDate("2010-10-31 23:59:59", new String[] { "yyyy-MM-dd HH:mm:ss" });
System.out.println(DurationFormatUtils.formatDuration(expo2010BeginDate.getTime() - now.getTime(), "d"));
System.out.println(DurationFormatUtils.formatDuration(expo2010BeginDate.getTime() - expo2010EndDate.getTime(),
"d"));
Duration formatting utilities and constants. The following table describes the tokens used in the pattern language for formatting.
以下是format参数
character | duration element |
---|---|
y | years |
M | months |
d | days |
H | hours |
m | minutes |
s | seconds |
S | milliseconds |
原文链接:
http://blog.csdn.net/kimsoft/article/details/5106984
相关文章推荐
- 使用 DurationFormatUtils 计算时间间隔
- 使用 DurationFormatUtils 计算时间间隔
- 使用 DurationFormatUtils 计算时间间隔
- C++计算当前时间点间隔N天的时间(不使用CTimeSpan类)
- 使用 performance-counter 计算时间间隔
- C#时间间隔计算(TimeSpan类的使用)
- python使用datetime模块计算各种时间间隔的方法
- Windows中如何计算时间间隔(1)使用CTime 和CTimeSpan
- 使用TIMESTAMPDIFF计算两个时间戳之间的时间间隔需要注意的细节
- Windows中如何计算时间间隔(1)使用CTime 和CTimeSpan
- Windows中如何计算时间间隔(2)使用SYSTEMTIME和FILETIME
- 一个简单方法完成C#时间间隔的计算
- 如何计算视频和音频的时间戳间隔时间
- 计算两个日期的时间间隔(C#)
- 使用QueryPerformance* api计算时间
- MySQL提供的可以计算两个时间间隔的函数
- c# 计算时间间隔
- 电池容量的使用时间计算
- python的N个小功能(文本字段对应数值,经纬度计算距离,两个时间点计算时间间隔)
- ORACLE 计算时间相减间隔