File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes related to Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "related to Date" Watch "related to Date" New topic
Author

related to Date

ashwini hikulkarni
Greenhorn

Joined: Jun 16, 2008
Posts: 25
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Abhijeet Nalawade
Greenhorn

Joined: Apr 01, 2007
Posts: 20
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

Joined: Jun 16, 2008
Posts: 25
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

Joined: Jun 16, 2008
Posts: 25
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

Joined: Apr 01, 2007
Posts: 20
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

Joined: Jan 28, 2003
Posts: 3950
    
  17

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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

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

Joined: Oct 27, 2005
Posts: 19543
    
  16

Yeah, that should be ma'am or lady


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: related to Date
 
Similar Threads
xsd datetime format
Time Zone problem
How to change Date Format
How to compare jstl value with String value
How to compare jstl value with String value