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
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.
[OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
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...
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 ]
Steve
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

[OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
