Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Coverting from String to Date.

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know how to convert from following String to Java.util.Date:

"15-SEP-06 10.27.31.436332 AM +05:30"

The above result is obtained when i get the System Time Stamp from Oracle database of mine.

Plesee help ASAP.
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the SimpleDateFormat class. Javadocs

You can pass a format in it's constructor and use the parse() method passing it the string.
 
Ankit Pradhan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tested the SimpleDateFormat class but none of the format supported for parsing will go with +5:30 part of the date string.

Please give me the format which could be used for parsing the string.

Thanks
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, right, you do seem to have a very special format. Can't you format the date differently when getting it from the DB? And why are you not getting a Date-object straight from the DB?

Anyways. Besides wondering why you have such a strange format coming out of your DB, I wrote a little bit of code parsing your date. It's definately not the best solution but I think it should work. I was also wondering how it is possible to live in a timezone +05:30?
In the code I truncated the time so we only have milliseconds (3 digits, not 6) and I removed the ":" in the timezone. SimpleDateformat seems to have difficulties with those 2 things. And voila ...


[ September 15, 2006: Message edited by: Manuel Moons ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I was also wondering how it is possible to live in a timezone +05:30?


I think you'd have to ask the people living in New Delhi and Mumbai that...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic