/* Get current time */
public static String GetCurrentTime () {
Date currenttime = new Date ();
SimpleDateFormat formatter = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
String datestring = Formatter.format (currenttime);
return datestring;
}
/* Time than size */
public static int Timecompare (String t1,string T2) {
SimpleDateFormat formatter = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
Calendar c1=calendar.getinstance ();
Calendar c2=calendar.getinstance ();
try {
C1.settime (Formatter.parse (t1));
C2.settime (Formatter.parse (T2));
} catch (ParseException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
int Result=c1.compareto (C2);
return result;
}
public static void Main (string[] args) {
// String coupon_valid_end = "3004-03-26 13:31:40";
// String currenttime = GetCurrentTime ();
// int flagnum = Timecompare (Coupon_valid_end, currenttime);
// System.out.println (Flagnum);
// }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Time string compared to current time