Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting String into Date Format

 
sailee phalak
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi PPL,

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 ???

thanks
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your input, and required output are the same format?
 
Sudhakar Kalk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> new SimpleDateFormat("yyyymmdd HHmmss");

do you really want
year-year-year-year minute-minute day-day
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic