You can use DateTimeFormatterBuilder to manually create a format. DTFormatter f = new DTFBuilder().appendPattern("yyyyMMddHHmmss").appendMillisOfSecond(2).toFormatter();
Stephen On 9 March 2012 12:25, Wojtek K <w...@kite-fu.co.uk> wrote: > Thanks for the answer. We have multiple external systems that keep > sending us timestamps in 'SS' format - two digits should be > interpreted as 0SS e.g.(13 should be treated as 13ms). > > Regardless the fact that Joda is right, I am wonder if there is a > right approach for conversion instead of doing string manipulation of > the input message? > > Regards > w. > > Quoting Stephen Colebourne <scolebou...@joda.org>: > >> 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 >> > > > > ------------------------------------------------------------------------------ > 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