• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert string to date format YYYYMMDDHH24MISS  RSS feed

 
suju hande
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
probably this is a beginner question not sure so posted here.

I have to do 2 things
convert a string into YYYYMMDDHH24MISS format before passing it to a plsql function
i.e if the date is 12/15/2007
the output should be 20071215141239

i am stuck as to what pattern to use in SimpleDateFormat

DateFormat df = new SimpleDateFormat("yyyyMMddHH24MISS");
it fails here saying I is invalid.
Please help!!
Thanks in advance
 
Francois Dang Ngoc
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sujata,

> DateFormat df = new SimpleDateFormat("yyyyMMddHH24MISS");

If we look at the Java API (http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html), we have the following:
- H: hour in day (0-24)
- m: Minute in hour
- s: Second in minute

So the pattern can be defined as: yyyyMMddHHmmss

Hope it helps,

Cheers,

Francois
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!