Reputation: 67454
I want the same result as this:
dateTime.toDate().getTime() + ""
NOTE: That + ""
converts it to a String
.
Does JodaTime's date formatter have a way to do this? I want to do something like this:
dateTime.toString(x);
to get the same result. I tried this:
new DateTime().toString("SSS")
But this prints the milliseconds in the second, which is not the same as the first example.
Upvotes: 0
Views: 71
Reputation: 14149
At first please note that dateTime.toDate().getTime()
returns time in millis not in seconds. Also there is no default date format to print date in millis. You can of course implement your own DateTimeFormatter
but it makes no sense compared to
String.valueOf(new DateTime().getMillis())
or
String.valueOf(new DateTime().getMillis()/1000)
if you want result in seconds
Upvotes: 2