tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <>
Subject Trouble parsing datetime strings
Date Mon, 11 May 2009 13:27:04 GMT
This is related to the performance issues discussed in the thread 
"Performance with many small requests".

When I reworked my servlet to synchronize only on pieces that needed to 
be synchronized, rather than on the entire request processing routine, I 
am now throwing an exception when parsing a string into a java.util.Date 
variable.  It only happens occasionally, maybe once every few dozen to a 
hundred or so requests, and I can't figure out why it doesn't work all 
the time.

Declared at the class level, I have:

    private static final SimpleDateFormat    sdfFullDateTime = new 
SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );

Then in the request processing method, I have

    dateTimeStr = dateStr + " " + timeStr;
    try {
        dataDate = sdfFullDateTime.parse( dateTimeStr );
    } catch ( Exception e ) {
        writeLog( "Unable to parse dataTime string: '", dateTimeStr + 
"': " + e );

(the try/catch is there only for debugging this issue), and in the log 
I'm seeing:

2009-05-11 09:19:54: Unable to parse dateTime string: ':  '2009-05-11 
09:19:37': java.lang.NumberFormatException: For input string: ""'

Which I don't understand at all; dateDate (java.util.Date), dateStr 
(String), timeStr (String) and dateTimeStr (String) are all declared in 
the processing method, NOT at the class level.

Maybe I should move the declaration of the SimpleDateFormat into the 
processing method?  Or synchronize the date parse?

I'm kind of lost here; any help appreciated!!


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message