Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "withZone()" and "toDateTime()" methods of joda DateTime

What is the difference between these two DateTime's methods?

DateTime.withZone(DateTimeZone zone)

DateTime.toDateTime(DateTimeZone zone)

??

They both seem to load the timezone, without touching the millis of the DateTime.

like image 241
user1028741 Avatar asked Oct 19 '22 21:10

user1028741


1 Answers

I believe they are identical. They perform the same function anyway. They appear to be implemented separately, rather than having one call the other. I'm unsure why.

The only difference I can see is that toDateTime must be implemented, because it is defined in AbstractInstant, and DateTime extends AbstractInstant.

like image 151
Matt Johnson-Pint Avatar answered Oct 22 '22 22:10

Matt Johnson-Pint