This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Lenin Chada
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you that solved my problem
new SimpleDateFormat("dd-MMM-yy")
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and thank you for sharing with us what you learned.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!