java - How to calculate 1 month ago in milliseconds? -


i want calculate 1 month ago current time in milliseconds. example if date 25.11.2016 want 25.10.2016 milliseconds format. how can calculate date milliseconds? below code not working think.

system.currenttimemillis() - 1000*60*60*24*30  

you can use way:

calendar c = calendar.getinstance(timezone.gettimezone("utc")); c.add(calendar.month, -1); long result = c.gettimeinmillis(); 

note system.currenttimemillis() using utc, need create instance of calendar using same timezone.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -