两个特定日期之间的区别

编程入门 行业动态 更新时间:2024-10-25 02:20:53
本文介绍了两个特定日期之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个日期20-03-2011和1-04-2011,存储为String.How我可以解析为日期格式,并计算两个日期之间的差异?

I have two dates 20-03-2011 and 1-04-2011,stored as String.How can I parse this into date format and calculate the difference between the two dates?

推荐答案

以下是一个解决方案,因为有很多方法可以实现这一点:

The following is one solution, as there are numerous ways we can achieve this:

import java.util.*; int syear = 2000; int eyear = 2000; int smonth = 2;//Feb int emonth = 3;//Mar int sday = 27; int eday = 1; Date startDate = new Date(syear-1900,smonth-1,sday); Date endDate = new Date(eyear-1900,emonth-1,eday); int difInDays = (int) ((endDate.getTime() - startDate.getTime())/(1000*60*60*24));

更多推荐

两个特定日期之间的区别

本文发布于:2023-10-18 23:52:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505790.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   两个   日期

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!