Advertisement
Advertisement
| 05.05.2008 at 12:51AM PDT, ID: 23375876 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: |
My Util.java
public static int getCompareResult2(String date) throws ParseException {
DateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
df.setLenient ( false );
DateFormat df1 = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyy", Locale.getDefault());
df1.setLenient ( false );
Date d1= df.parse(date);
Date now = df1.parse(new Date().toString());
Calendar today = Calendar.getInstance(Locale.getDefault());
today.setTime(now);
Calendar compare = Calendar.getInstance(Locale.getDefault());
compare.setTime(d1);
compare.set(Calendar.HOUR_OF_DAY, 0);
compare.set(Calendar.MINUTE, 0);
compare.set(Calendar.SECOND, 0);
compare.set(Calendar.MILLISECOND, 0);
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
if (today.equals(compare)) {
return 0;
} else if(today.before(compare)) {
return -1;
} else {
return 1;
}
}
|