This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Convert string to date format YYYYMMDDHH24MISS

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic