1
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());

我需要知道 zCurrentDateTimeL 和 zUpdatedDateTimeG 之间的日期时间

怎么做?

4

2 回答 2

1

试试这个:我希望这对你有帮助这对我有用......

        private void getDifference(java.util.Date startTime,
            java.util.Date endTime, java.util.Date eartime,
            java.util.Date curtime) {

        Calendar startDateTime = Calendar.getInstance(TimeZone
                .getTimeZone("GMT-5:00"));
        startDateTime.setTime(startTime);
        Calendar endDateTime = Calendar.getInstance();
        endDateTime.setTime(endTime);           
        long milliseconds1 = startDateTime.getTimeInMillis();
        long milliseconds2 = endDateTime.getTimeInMillis();
        long diff = Math.abs(milliseconds1 - milliseconds2);
        long seconds = diff / (1000);

              }
于 2013-02-15T09:44:39.027 回答
1
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();

这将返回以毫秒为单位的差异

于 2013-02-15T09:47:06.913 回答