• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problem in Coverting one Date Format to Other date Format

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the error you are getting?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic