File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes converting String into Date Format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "converting String into Date Format" Watch "converting String into Date Format" New topic

converting String into Date Format

sailee phalak

Joined: Jul 03, 2007
Posts: 1

I am having some problem in java code.

I am getting one string in particular format like "20051010 102533"
this string is in "yyyymmdd HHmmss" format .

now i want this string to convert this Date object.

i am using following approch but it is not giving me expected output.

now i am getting something like TUE 25 JUNE 10:25:33 IST etc ... where as i want the date in following format like "20051010 102533 " .

Is it possible ???

Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Your input, and required output are the same format?
Sudhakar Kalk

Joined: Jul 02, 2007
Posts: 3
When accessing the Date object it prints in the standard format only. So, if you want it in a specified format convert into String.
[ July 03, 2007: Message edited by: Sudhakar K ]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

"Sudhakar K",
Welcome to JavaRanch!

We're pleased to have you here with us here on the ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. You can change it here

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> new SimpleDateFormat("yyyymmdd HHmmss");

do you really want
year-year-year-year minute-minute day-day
I agree. Here's the link:
subject: converting String into Date Format
It's not a secret anymore!