Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
String strDate = sdf.format(c.getTime());
---------------------------------for compare------------------------------
try{
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String str1 = "12/10/2013";
Date date1 = formatter.parse(str1);
String str2 = "13/10/2013";
Date date2 = formatter.parse(str2);
if (date1.compareTo(date2)<0)
{
System.out.println("date2 is Greater than my date1");
}
}catch (ParseException e1){
e1.printStackTrace();
}
No comments:
Post a Comment