?
Solved

date substraction issue

Posted on 2012-04-05
1
Medium Priority
?
286 Views
Last Modified: 2012-04-05
The following code is producing a difference of "300000".
I am trying to get "05".   What am I doing wrong or what additional step do I need?

Code Snippet:

          String Time1 = "2011-09-21T22:30:00Z";
          String Time2 = "2011-09-21T22:35:00Z";
          DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
         
          try {
             long a = dfm.parse(Time1).getTime();
             long b = dfm.parse(Time2).getTime();
             long c = (b-a);
             Long diff = new Long(c);
             System.out.println(forecastTime +"-" + currentTime + "=" + diff.toString());
          } catch (Exception e) {
             e.printStackTrace();
          }
0
Comment
Question by:dpalyca755
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 37814001
divide by 60,000 (number of miliseconds in a minute)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question