This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Comparing dates.....Help.....Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Comparing dates.....Help.....Please " Watch "Comparing dates.....Help.....Please " New topic

Comparing dates.....Help.....Please

Lenin Chada

Joined: Mar 10, 2003
Posts: 3
Iam trying to compare two dates i am getting the following error, can anybody please help me
java.text.ParseException: Unparseable date: "21-DEC-03"
at java.text.DateFormat.parse(
at java.util.Arrays.mergeSort(
at java.util.Arrays.mergeSort(
at java.util.Arrays.sort(
at Sample.Sample.main(
here is my code
SimpleDateFormat sdf = new SimpleDateFormat("dd-mon-yy");
Date d1 = sdf.parse(r1[column]);
Date d2 = sdf.parse(r2[column]);
int result = d1.compareTo(d2);
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

new SimpleDateFormat("dd-mon-yy");

"dd-mon-yy" is not a valid format specifier. Check out the JavaDoc for SimpleDateFormat for legal formatting.

[Asking smart questions] [About Bear] [Books by Bear]
Lenin Chada

Joined: Mar 10, 2003
Posts: 3
thank you that solved my problem
new SimpleDateFormat("dd-MMM-yy")
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
...and thank you for sharing with us what you learned.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Comparing dates.....Help.....Please
It's not a secret anymore!