it would be better to declare MILLIS_IN_DAY as long because if the above code gets used to calculate couple of days in the past i.e.
int numberOfDays = 40;
dateFormat.format(date.getTime() - MILLIS_IN_DAY * numberOfDays );
if the numberOfDays is greater than 24 days, milliceconds will be added not subtracted because of the overflow
The code shown is not getting complied. The reason is, it is passing date.getTime() to java.text.DateFormatter.formate method and formate method should take Date object.But here date.getTime() will return Long Object.
Please do it correct accordingly .
be very careful with int type for MILLIS_IN_DAYmarko February 28, 2012 at 6:21 PM
it would be better to declare MILLIS_IN_DAY as long because if the above code gets used to calculate couple of days in the past i.e. int numberOfDays = 40; dateFormat.format(date.getTime() - MILLIS_IN_DAY * numberOfDays ); if the numberOfDays is greater than 24 days, milliceconds will be added not subtracted because of the overflow
Getting Previous, Current and Next Day DateIndu May 28, 2012 at 3:58 PM
The code shown is not getting complied. The reason is, it is passing date.getTime() to java.text.DateFormatter.formate method and formate method should take Date object.But here date.getTime() will return Long Object. Please do it correct accordingly .
Post your Comment