0

I am using SimpleDateFormat to get the difference between two Dates and with the new Date I am trying to break that down into days, hours, minutes, seconds, ms without using Joda libraries. I am able to use the apache commons-lang library which looks like it is able to do it but with only one type of metric (ie. I can't use hours, minutes and seconds. I can only convert to either hours OR minutes or seconds).
Example of what I am trying to do.

Date1 = 1/2/2014 12:35:57.04  
Date2 = 1/1/2014 12:34:55.01  
Newdate = 1/1/2014 00:01:02.03  
Output = 1d 00h 01m 02s 03ms  

The reason I am trying to avoid using Joda time and I am trying to use apache commons is I am trying to avoid using any extra libraries (if possible).

Cœur
  • 37,241
  • 25
  • 195
  • 267
user3684399
  • 165
  • 2
  • 9
  • possible duplicate of [Display days, hours, minutes in between 2 dates in java](http://stackoverflow.com/questions/19664696/display-days-hours-minutes-in-between-2-dates-in-java) – Basil Bourque Jan 27 '15 at 19:00
  • possible duplicate of [How to find the duration of difference between two dates in java?](http://stackoverflow.com/questions/17940200/how-to-find-the-duration-of-difference-between-two-dates-in-java) – Duncan Jones Jan 28 '15 at 07:56
  • What about this [apache-lang-commons-method](http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/DurationFormatUtils.html#formatDurationWords(long, boolean, boolean))? – Meno Hochschild Jan 28 '15 at 13:19

0 Answers0