• 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

SimpleDateFormat

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having an issue with a web app I'm working on where it reads in a date from a mainframe DB, parses it, then displays it on a page.

The problem is the date comes in as a resultset string. the Format is "2006111"

Where it's the yyyy and Day of the Year.

I can read it in, parse it, and then display it on the jsp page and table.

However I need it to display as 4/04/2006 and not 2006111.

I'm stuck on how to convert day of year into the correct format..

I've did format it, but it comes out like 20/06/1111 and so on. Not what I need.

Any help would be greatly appreciated.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep in mind that the date format is case sensitive -- having a different case will have a different meaning. Anyway, try...



Henry
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI friend,
I am assuming that you require to maintain the current system date in your require format .
i am pasting some code here that wil work surely cuase it works on my side.

SimpleDateFormat dat= new SimpleDateFormat("dd/MM/yyyy");
String str= dat.format(d);

It wil give you the current date in your format.
And even you can get the time by,
SimpleDateFormat dat1= new SimpleDateFormat("HH-mm-ss");
String str1= dat1.format(d);

SO you use this ,ANd if have any issue again remember me .

Enjoy with the coding..

Jay Java..
 
Isaac Mcmahnus
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the .applyPattern. It seems to work.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic