please tell me how to convert milliseconds to joda Date time??
formatter = DateTimeFormat.forPattern("dd/MM/yyyy'T'HH:mm:ss").withZone(DateTimeZone.forOffsetHoursMinutes(00, 00));
even tried
String millisecond="14235453511" DateTime.parse(millisecond);
An interval in Joda-Time represents an interval of time from one instant to another instant. Both instants are fully specified instants in the datetime continuum, complete with time zone.
How do you convert datetime to milliseconds? A simple solution is to get the timedelta object by finding the difference of the given datetime with Epoch time, i.e., midnight 1 January 1970. To obtain time in milliseconds, you can use the timedelta. total_seconds() * 1000 .
Joda-Time provides a comprehensive formatting system. There are two layers: High level - pre-packaged constant formatters. Mid level - pattern-based, like SimpleDateFormat. Low level - builder.
Joda-Time provides a quality replacement for the Java date and time classes. Joda-Time is the de facto standard date and time library for Java prior to Java SE 8. Users are now asked to migrate to java. time (JSR-310). Joda-Time is licensed under the business-friendly Apache 2.0 licence.
The answer given by @Adam S is almost okay. However, I would prefer to specify the timezone explicitly. Without specifying it you get the constructed DateTime
-instance in the system timezone. But you want the zone "0000" (UTC)? Then look for this alternative constructor:
String milliseconds = "14235453511"; DateTime someDate = new DateTime(Long.valueOf(milliseconds), DateTimeZone.UTC); System.out.println(someDate); // 1970-06-14T18:17:33.511Z
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With