• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic