Yes there is a difference. Joda-Time is correct and SimpleDateFormat is wrong.
0.91 is 91/100th of a second, which is 910ms Stephen On 9 March 2012 10:29, Wojtek K <w...@kite-fu.co.uk> wrote: > Hi All, > > Is there a difference between DateTimeFormatter and SimpleDateFormat > in respect of parsing milliseconds? This is my test code: > > String pattern = "yyyyMMddHHmmssSS"; > > SimpleDateFormat javaDateFormatter = new SimpleDateFormat(pattern); > DateTimeFormatter jodaDateFormatter = DateTimeFormat.forPattern(pattern); > > String tsStr = "2012.03.07.17.15.07.91".replace(".", ""); > > // SimpleDateFormatwill parse 91 as 91ms, Joda 2.0 will parse it as 910ms > Date javaDate = javaDateFormatter.parse(tsStr); > Date jodaDate = jodaDateFormatter.parseDateTime(tsStr).toDate(); > assertThat(jodaDate.getTime() - 910 + 91, equalTo(javaDate.getTime())); > > Regards > Wojtek > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest