![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e317. Parsing the Time Using a Custom FormatA pattern of special characters is used to specify the format of the time to parse. The same set of pattern characters are used to parse times. See e316 Formatting the Time Using a Custom Format for a listing of some pattern characters. Note: This example formats dates using the default locale
(which, in the author's case, is try { // Some examples DateFormat formatter = new SimpleDateFormat("hh.mm.ss a"); Date date = (Date)formatter.parse("02.36.33 PM"); formatter = new SimpleDateFormat("HH:mm:ss Z"); date = (Date)formatter.parse("22:14:02 -0500"); } catch (ParseException e) { }
e318. Formatting and Parsing a Time for a Locale Using Default Formats e319. Formatting and Parsing a Time for a Locale
© 2002 Addison-Wesley. |