Android Question Is DateTime.DateFormat permanent?

carlospc

Member
Licensed User
Longtime User
Hello.

I was reading that I had to save the current value of DateFormat, change it, do some code related to the date, and the revert it back.

Was I reading right? I thought that I could set the DateFormat in Starter and forget it.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

emexes

Expert
Licensed User
Longtime User
I was reading that I had to save the current value of DateFormat, change it, do some code related to the date, and then revert it back.

If you always set DateFormat before you use it, without any other changes to it in-between where you set it and where you use it, then you don't have to do the save and revert. And a trap with save-and-revert is that there are often ways for program flow to escape before the revert eg if an exception occurs, or you have a break or a return in-between.

On the other hand, from a defensive programming perspective, it's also a good habit to leave things as you found them, just in case.
 
Upvote 0
Top