Expiring date today in Java -
I need to see today that the date given is today after 23:59:59, How can I create: 59: 59?
Use:
calendar cal = Calendar.getInstance () ; // represents now, i.e. today's date cal.set (calendar.HOUR_OF_DAY, 23); Cal.set (Calendar minutes, 59); Cal.set (calendar. SECOND, 59); Cal.set (calendar. Millisecond, 99); // date of date to date f1sh = cal.getTime ();
I think you can get it from a little wrong angle, though. Rather than trying to make an atom before midnight, a better method could be to make that date which reflects at midnight and tests that the current time strictly less than that I believe that it would be a bit clearer to read the code to anyone else in terms of your intentions.
Alternatively, you can use a third party date API that knows how to convert back date. Java's built-in date API is generally considered to be a defect in many ways. I do not recommend using any other library to do this, but if you have to manipulate a lot of dates and / or are already using a library like you express this concept more easily For example, in the add-on, there is a datamadrite
class in the case of subtle problems (such as the possibility of not setting a millisecond in my first cut Ina, you're way, allowing easy comparison against the "raw" dates).
Comments
Post a Comment