aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Comparing dates.....Help.....Please " Watch "Comparing dates.....Help.....Please " New topic
Author

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

Lenin Chada
Greenhorn

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(DateFormat.java:324)
at Sample.StringCompare1.compare(Sample.java:121)
at java.util.Arrays.mergeSort(Arrays.java:1181)
at java.util.Arrays.mergeSort(Arrays.java:1188)
at java.util.Arrays.sort(Arrays.java:1128)
at Sample.Sample.main(Sample.java:75)
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
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

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

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lenin Chada
Greenhorn

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

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: http://aspose.com/file-tools
 
subject: Comparing dates.....Help.....Please
 
Similar Threads
tomahawk datatable sorting
problem with dates
comparing date
how to find how many sundays comes in 2 Dates
How to compare 2 Dates in String Format