File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Date Format Problem
Joined: Aug 26, 2004
Jul 19, 2006 00:26:00
I have date which is in the format 2006-04-21 23:31:48.0
str_dt = 2006-04-21 23:31:48.0
When I used format_dt = inputFormat.parse(str_dt);
I am getting excpetion
: Unparseable date: "2006-04-21 23:31:48.0"
How can I resolve this? I need to format my date and insert into oracle database with date and time.
Thanks in advance
Never take anything for granted because you never know when you will lose it
Joined: Nov 24, 2005
Jul 19, 2006 00:47:00
You should set the proper format first:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); Date fDate = format.parse( "2006-04-21 23:31:48.2"); System.out.println(fDate); Calendar cal = Calendar.getInstance(); cal.setTime(fDate); System.out.println(cal);
All roads lead to JavaRanch
I agree. Here's the link:
subject: Date Format Problem
error in formatting miliseconds for date objects
Date Time conversion
how to convert string into string array
sql date convert
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015