Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

date parse  RSS feed

 
Hilton Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
Just trying to get this simple date program to work but it keeps
throwing the exception. I've tried swopping the month, respelling the month
and even restructuring the entire string ut nothing!! Please lend your input to this
simple peasant of little knowledge

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct format for the input depends on your locale. The default for the US locale looks like "Jan 1, 2003" so you might try that first. If you're located someplace else, your JDK (or OS) installation might not be set up for your actual locale, so you might try, e.g. DateFormat.getDateInstance(Locale.UK) to set the locale explicitly.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you receive a date in a format that differs from the default for your locale you can alway override it. Like this:

This parses correctly. You can check the documentation for java.text.SimpleDateFormat to see what your options are.
 
Hilton Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you by any chance have an address that has all the formats for the months, days and years. such as month MMM, ect.
Thnx
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my previous post I reference the documentation for java.text.SimpleDateFormat which shows you all of the valid codes ;-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!