Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28178
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: convert "01-Apr-08.12:38:04" to Date object |
| Date | 2014-04-22 09:03 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <lj5pbg$33s$1@dont-email.me> (permalink) |
| References | <74faf831-a90b-45d3-ae0e-18971856d9fc@googlegroups.com> |
On 4/22/2014 8:38 AM, mike wrote:
> Hi,
>
> How can I convert this:
>
> String time = "01-Apr-08.12:38:04";
>
> SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy'.'hh:mm:ss ");
>
> try {
> Date date = dateFormat.parse(time);
> } catch (ParseException e) {
> e.printStackTrace();
>
> }
>
> I get the following:
>
> java.text.ParseException: Unparseable date: "01-Apr-08.12:38:04"
> at java.text.DateFormat.parse(DateFormat.java:337)
>
>
> Any ideas on how I can work around this?
As you've constructed it, `dateFormat' requires a trailing space,
but `time' doesn't have one.
Also, I'm not too sure that using "hh" without an AM/PM indicator
is a good idea. It's possible that parse() objects to the ambiguity.
--
Eric Sosman
esosman@comcast-dot-net.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
convert "01-Apr-08.12:38:04" to Date object mike <mikaelpetterson@hotmail.com> - 2014-04-22 05:38 -0700
Re: convert "01-Apr-08.12:38:04" to Date object Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-22 09:03 -0400
Re: convert "01-Apr-08.12:38:04" to Date object mike <mikaelpetterson@hotmail.com> - 2014-04-22 06:57 -0700
csiph-web