This content has been marked as final. Show 3 replies
... I've found that 80% of the errors occur the first time the SimpleDateFormatter is called.But each call to fixDateForCorp creates a new SimpleDateFormat, which is only used once, so I don't understand what that means.
However, just a couple of observations that may or may not be useless:
Your examples are all off by an exact number of days; not by an exact multiple of 24 hours, since there would be a daylight-saving change between the "bad" and "good" versions. (At least there is in my timezone, maybe not in yours.)
It is the MySQL JDBC driver that is creating those Timestamp objects, so it is possible that is where the error occurs.
SimpleDateFormat is not thread-safe; are there multiple threads involved here?
Thanks for responding DrClap.
But each call to fixDateForCorp creates a new SimpleDateFormatYes, I'm grasping for straws on this one.
Your examples are all off by an exact number of days;Here's some more examples, Sorry bad sample of data the first time.
It is the MySQL JDBC driver that is creating those Timestamp objects, so it is possible that is where the error occurs.Interisting idea. For fun I did a toString() on the date that MySql returns, to my suprise it looked like this:
Leading zeros, just replace the space with the "+", kill the milliseconds and that should do it. Not using the formatter at all. I'm going to try this and it will nail the driver if it continues to fail.
SimpleDateFormat is not thread-safe; are there multiple threads involved here?A flag is set to determine if the record is sent and persists the data in the MySql table. Periodically, a record set of unreplicated records is retrieved and sent to the server. I have to create a new url for each push in the record set so I'm pretty certain that multiples are not called. I've written a thread handler as well to prevent multiple calls of the replication methods.
I'm going to try the toString() method for creating the string. I'll post here the results for anyone else having this problem. Will be a month or so before it's distributed though.
This is a post on how I fixed the problem and possible cause.
The date formatter was not the problem at all. I suspect it is the MySql driver or a database collision causing the wierdness. I tried to replicate the problem to no avail.
To fix this, I used the toString() function of the date object returned. After conversion, I sent a select/count/where statement to the database using the string and counted for one record and if successfull, I sent it. So far using this method, no odd dates have been sent.
Thanks to all who helped me with this.