• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.text.SimpleDateFormat

 
K. Tsang
Bartender
Posts: 3457
14
Android Java
  • Mark post as helpful
  • send pies
  • 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: 3457
14
Android Java
  • Mark post as helpful
  • send pies
  • 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"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic