• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date format related question  RSS feed

 
srikanth darbha
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the below code

String o_date1 = o_date+" "+al_times.get(p);
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-mm-yyyy hh:mm");
java.util.Date date1 = sdf.parse(o_date1);
System.out.println("d1---------------------------"+date1);


where o_date is an string value 05/01/2014
and al_times.get(p)=09:09

now when i am trying to print i am getting an exception Unparseable date: "07/01/2014 09:01"
at java.text.DateFormat.parse(DateFormat.java:337)

can anyone please help me out
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do check your date format. First you are using slash ("/") for your date separator when the pattern expects a dash. Second your time 24 hour, do look for 24 hour" hour format.

Hint: HH vs hh for hour and mm vs MM for minute or month
 
srikanth darbha
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Do check your date format. First you are using slash ("/") for your date separator when the pattern expects a dash. Second your time 24 hour, do look for 24 hour" hour format.

Hint: HH vs hh for hour and mm vs MM for minute or month


Thanks man small mistake have just replaced '-' with / it is working fine have overlooked that..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!