• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Coverting one Date Format to Other date Format

 
S Sankar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error you are getting?
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
S Sankar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!