Link to home
Start Free TrialLog in
Avatar of dpalyca755
dpalyca755

asked on

date substraction issue

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();
          }
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial