• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

related to Date

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Jeanne Boyarsky
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, that should be ma'am or lady
 
Get me the mayor's office! I need to tell her about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic