如何找到两个日期是字符串格式在android系统的区别 [英] How to find difference between two dates which is in string format in android
本文介绍了如何找到两个日期是字符串格式在android系统的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
日历zCalendarL = Calendar.getInstance();
SimpleDateFormat的zDateFormatL =新的SimpleDateFormat(YYYY / MM / DD HH:MM:SS);字符串日期时间=2013年2月15日15时05分01秒;
字符串zUpdatedDateTimeG = zDateFormatL.format(日期时间);串zCurrentDateTimeL = zDateFormatL.format(zCalendarL.getTime());
我需要知道zCurrentDateTimeL和zUpdatedDateTimeG之间的日期和时间
怎么办呢?
解决方案
日历zCalendarL = Calendar.getInstance();
SimpleDateFormat的zDateFormatL =新的SimpleDateFormat(YYYY / MM / DD HH:MM:SS);字符串日期时间=2013年2月15日15时05分01秒;日期D = zDateFormatL.parse(日期时间);
长差异= System.currentTimeMillis的() - d.getTime();
这将返回在毫秒之差
Calendar zCalendarL = Calendar.getInstance();
SimpleDateFormat zDateFormatL = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String DateTime="2013/02/15 15:05:01";
String zUpdatedDateTimeG =zDateFormatL.format(DateTime);
String zCurrentDateTimeL=zDateFormatL.format(zCalendarL.getTime());
I need to know the date time between zCurrentDateTimeL and zUpdatedDateTimeG
How to do it?
解决方案
Calendar zCalendarL = Calendar.getInstance();
SimpleDateFormat zDateFormatL = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String DateTime="2013/02/15 15:05:01";
Date d = zDateFormatL.parse(DateTime);
long diff = System.currentTimeMillis() - d.getTime();
this will return the difference in miliseconds
这篇关于如何找到两个日期是字符串格式在android系统的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文