Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

related to Date

 
ashwini hikulkarni
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me out to convert the date format to mm/dd/yyyy hh:mm PM
but i am unable to get the value .My code is below

when i am printing the value of

on console it is showing in this format >> Wed Jul 16 18:31:04 GMT+05:30 2008
and i want the date to be displayed in this >>> mm/dd/yyyy hh:mm PM - format please Help
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashwini,
It sounds like you want to match "Wed Jul 16 18:31:04 GMT+05:30 2008" and are trying "dd/MM/yyyy" as the format. Clearly this won't work. What happens when you try writing a format expression that represents the full string based on the format symbols in SimpleDateFormatter.

You will likely find it easier to write a test program so you can gradually match one symbol at a time. For example, can you match:
"Jul 16 2008"
"Jul 16 2008 18:31:04"
"Wed Jul 16 2008 18:31:04"
"Wed Jul 16 18:31:04 2008"
"Wed Jul 16 18:31:04 GMT+05:30 2008"

Post which of these you get stuck on and what format string you are trying. People will be happy to help with that, but unlikely to write the whole format string for you.
 
Abhijeet Nalawade
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To display date in : mm/dd/yyyy hh:mm PM format


Please make changes to argumnet passed to SimpleDateFormat class as below.

 
ashwini hikulkarni
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir Jeanne
I have shown ,just an example . I dont want to match that value but the value which i am printing on console is:: Wed Jul 16 18:31:04 GMT+05:30 2008 ,, so the format i need is MM/dd/yyyy ... so where i am confused is , i dont want to show the date in this fashion ( Wed Jul 16 18:31:04 GMT+05:30 2008).... I want the date to be displayed in in this fashion 7/16/2008...
 
ashwini hikulkarni
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Abhijeet Nalawade:


Please make changes to argumnet passed to SimpleDateFormat class as below.




Abhijeet i want to convert the formatt of the date and then display the date in
 
Abhijeet Nalawade
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you getting any exception while parsing or converting the date using the SimpleDateFormat API?
The SimpleDateFormat class formats the date to the form we specify to its constructor.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont want to match that value but the value which i am printing on console is:: Wed Jul 16 18:31:04 GMT+05:30 2008 ,, so the format i need is MM/dd/yyyy ... so where i am confused is , i dont want to show the date in this fashion ( Wed Jul 16 18:31:04 GMT+05:30 2008).... I want the date to be displayed in in this fashion 7/16/2008...


You have a String as an input, and a String as an output. Between the two you need to get to date.

So as Jeanne suggests, first try to parse a small portion of the incoming String, then display that part in the output.

For example, you have the String:
"Wed Jul 16"
Can you parse just the Day of Week, Month, and Day of Month out of that into a new Date, then display the new Date in MM/dd format?

Then add the time. Then add the time zone. Then add the year.
[ August 10, 2008: Message edited by: Steve Luke ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve Luke:
You have a String as an input, and a String as an output. Between the two you need to get to date.

Thanks for wording this so clearly!

Ashwini: fyi - I'm female so better not to address me with 'sir' in the future
 
Rob Spoor
Sheriff
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that should be ma'am or lady
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic