java - Compare current date with date from property file -


i getting hard coded date property file , of format dd-mmm-yyyy.

now need compare current date of same format. purpose , cooked piece of code :

date convdate = new date(); date currentformatteddate = new date(); dateformat dateformat = new simpledateformat("dd-mmm-yyyy"); convdate = new simpledateformat("dd-mmm-yyyy").parse("20-aug-2013"); currentformatteddate = new date(dateformat.format(currentformatteddate));  if(currentformatteddate.after(convdate) || currentformatteddate.equals(convdate)){   system.out.println("correct"); }else{   system.out.println("in correct"); } 

but eclipse tells me new date has been depreciated. 1 know of alternative way of doing ? going crazy on this. !

one of way use calendar class , after() , equals() , before() methods.

calendar currentdate = calendar.getinstance(); calendar anotherdate = calendar.getinstance(); date convdate = new simpledateformat("dd-mmm-yyyy").parse("20-aug-2013"); anotherdate.settime(convdate); if(currentdate .after(anotherdate) ||     currentdate .equals(anotherdate)){     system.out.println("correct"); }else{    system.out.println("in correct"); } 

you can use jodatime library , see this answer.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -