• 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

java.text.SimpleDateFormat

 
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
Hi all, I'm doing UB assignment and in my book GUI I have a set of date combo boxes to select the year, month, day.

I use a Room object to pass the values to my services layer where the update is done. In the services layer, I use the java.text.SimpleDateFormat("yyyy/mm/dd") constructor to get my date from java.util.Date (from Room) to a string "yyyy/mm/dd" for the data file.

Now guess what? Suppose I select Jan 13 2010 in my combo boxes, the SimpleDateFormat outputs "2010/18/13" yet my GUI displays as Jan 13 2010 for that record. Then I restart my app that same record become Jun 13 2011 - that's like 18 months off.

Any one use this class for their assignment? Before I use SimpleDateFormat I physically did convert the java.util.Date to a string using its toString method and split that up and get the appropriate array index.
 
K. Tsang
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
Nevermind I figured it out. The format I should have used was "yyyy/MM/dd" instead of "yyyy/mm/dd"
 
We cannot change unless we survive, but we will not survive unless we change. Evolving 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