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 Problem in Coverting one Date Format to Other 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 "Problem in Coverting one Date Format to Other date Format" Watch "Problem in Coverting one Date Format to Other date Format" New topic
Author

Problem in Coverting one Date Format to Other date Format

S Sankar
Greenhorn

Joined: Jul 31, 2007
Posts: 4
Hi,

I have a string like "2009-04-01 12:19:23.14+05:30" i want to convert this to "April 01, 2009 - 12:19 am",

i need to convert this string into some other date format, but i tried with following way, but it is giving exception,
is there any other way to covert this....

I tried in the following way but it is not working..

SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy - hh:mm aaa");
SimpleDateFormat sourcesdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.sssz");

java.util.Date date = sourcesdf.parse("2009-04-01 12:19:23.14+05:30");
sdf.format(date)

is there any other way to convert this...
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
What is the error you are getting?


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2627
    
    9

Try removing your colon in your timezone portion. I tried it and it's not what you will expect. The timezone is wrong. It's my timezone.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
S Sankar
Greenhorn

Joined: Jul 31, 2007
Posts: 4
K. Tsang wrote:Try removing your colon in your timezone portion. I tried it and it's not what you will expect. The timezone is wrong. It's my timezone.


Hi Tsang,

Thanks for your reply. This value i am getting from database. So i am not suppose to change this by removing the colon. Instead of i am looking for a Date Format for this.

James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
sankar sammiti wrote:Hi,

I have a string like "2009-04-01 12:19:23.14+05:30" i want to convert this to "April 01, 2009 - 12:19 am",

i need to convert this string into some other date format, but i tried with following way, but it is giving exception,
is there any other way to covert this....

I tried in the following way but it is not working..

SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy - hh:mm aaa");
SimpleDateFormat sourcesdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.sssz");

java.util.Date date = sourcesdf.parse("2009-04-01 12:19:23.14+05:30");
sdf.format(date)

is there any other way to convert this...






Hi,

If you want to get in the format of "Apr 01 2009 - 12:19 AM" then why don't you go for


it will give you the above output.

Thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Coverting one Date Format to Other date Format