|
|
back to boardWA19: using java's Date to calculate time difference is a mistake - it calculates it in not trivial way Posted by messir 27 Aug 2010 08:06 Re: WA19: using java's Date to calculate time difference is a mistake - it calculates it in not trivial way I also had WA 19. There are some tricks to get AC in Java using java.util.Date. Take your tambourine and let's go! 1. Divide milliseconds count by 24*60*60*1000. 2. January's index is 0, not 1. 3. Use, for example, year-1500 instead of year. 4. Use Date's deprecated constructor. Re: WA19: using java's Date to calculate time difference is a mistake - it calculates it in not trivial way Posted by ucs6 26 Apr 2012 12:00 You don't have to care about all those details. Use GregorianCalendar it will take care everything for you. |
|
|