Comparing mysql database date with current java date
/***
*/
package Date;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author deep
*
* program compares todays date with that in db
*
*/
public class JavaDate {
/**
* @param args
*/
public static void main(String[] args) {
String dateInDB = "2011-1-12";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String currentDate = format.format(new Date());
System.out.println(" Current date : " +currentDate);
System.out.println(" date in db : " +dateInDB);
if(currentDate.compareTo(dateInDB) <= 0)
System.out.println("current date is greater ");
else
System.out.println("db date is greater ");
}
}
Thanking you....
Happy New year 2013
ReplyDelete