on 09-15-2008 8:36 PM
Hi,
I am new to webdynpro java. I have a requirement. I am getting date in format "yyyymmdd" as string and i need to compare it to todays date.
Please help me how to do this.
Thanks,
Raz
Hi,
The way of comparing two date instances is same in WD Java as in plain Java. Assuming you already have got the date value as string from the context, use this code:
String dateStr = "<your value from the context>"; //for example 20071231
SimpleDateFormat f1 = new SimpleDateFormat("yyyyMMdd");
try {
Date d1 = f1.parse(dateStr);
Date d2 = new Date(System.currentTimeMillis()); //today's date
d1.compareTo(d2); // will return -ve if lhs is before rhs, +ve if ihs is after rhs & 0 if both the dates are equal.
} catch (ParseException e) {
e.printStackTrace();
}
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.