Click here to Skip to main content
15,867,704 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: RateOfInterest... Pin
BobJanova11-Jul-12 0:44
BobJanova11-Jul-12 0:44 
GeneralRe: RateOfInterest... Pin
PIEBALDconsult11-Jul-12 3:50
mvePIEBALDconsult11-Jul-12 3:50 
GeneralRe: RateOfInterest... Pin
BobJanova11-Jul-12 4:38
BobJanova11-Jul-12 4:38 
GeneralRe: RateOfInterest... Pin
Sandeep Mewara11-Jul-12 7:14
mveSandeep Mewara11-Jul-12 7:14 
GeneralRe: RateOfInterest... Pin
PIEBALDconsult11-Jul-12 8:37
mvePIEBALDconsult11-Jul-12 8:37 
JokeRe: RateOfInterest... Pin
S Houghtelin10-Jul-12 11:21
professionalS Houghtelin10-Jul-12 11:21 
GeneralRe: RateOfInterest... Pin
greldak10-Jul-12 22:07
greldak10-Jul-12 22:07 
GeneralDating Pin
V.10-Jul-12 3:56
professionalV.10-Jul-12 3:56 
I hope this counts as a subtle bug and can help those encountering something similar.

I'm reading in a bunch of data from files. Basically a datetime (dts) and a float value. Because we're talking about 1.3 million records which I read in with several files, create a list of insert queries and execute them by 100 at the time. Everything worked except for some batches.

So looking at the errors, it says it runs into a unique constraint (dts is unique). Fine, what value was double then? none.
Confused | :confused: is my state of mind by now. So I continue looking and print out the failed batches and sure enough there are double values in there. Checking the corresponding files : no doubles. But what does my little eye spy? double dts values start with 3 'o clock and only at the end of march! Daylightsaving (DTS).

The bug: I use java's GregorianCalendar and if you don't specify the timezone it will convert the 2:00 until 3:00 to 1 hour +. so 2:30 becomes 3:30 etc... What is strange though, is that there is no warning, no exceptions nothing. Just implicit conversion.

Perhaps it is my misunderstanding of the object, but if you encounter something similar, you just might want to check in this direction.

PS: I considered this forum to be the replacement of subtle bugs.

[EDIT]
The solution is to set the timezone to UTC.
If you use de SimpleDateFormat class to format the dates to string. This also has a timezome, which you also need to set to UTC to avoid having the date converted.
[/EDIT]
V.


modified 11-Jul-12 2:45am.

GeneralRe: Dating Pin
Brisingr Aerowing10-Jul-12 13:57
professionalBrisingr Aerowing10-Jul-12 13:57 
GeneralRe: Dating Pin
Peter_in_278010-Jul-12 14:13
professionalPeter_in_278010-Jul-12 14:13 
GeneralRe: Dating Pin
V.11-Jul-12 9:14
professionalV.11-Jul-12 9:14 
GeneralRe: Dating Pin
jschell11-Jul-12 8:09
jschell11-Jul-12 8:09 
JokeRe: Dating Pin
walterhevedeich10-Jul-12 19:26
professionalwalterhevedeich10-Jul-12 19:26 
GeneralRe: Dating Pin
BobJanova11-Jul-12 4:38
BobJanova11-Jul-12 4:38 
GeneralRe: Dating Pin
Andrei Straut11-Jul-12 6:19
Andrei Straut11-Jul-12 6:19 
GeneralRe: Dating Pin
UNCRushFan15-Jul-12 12:46
UNCRushFan15-Jul-12 12:46 
GeneralRe: Dating Pin
jschell11-Jul-12 8:11
jschell11-Jul-12 8:11 
GeneralYou know it's time to go home... Pin
StM0n10-Jul-12 2:59
StM0n10-Jul-12 2:59 
GeneralRe: You know it's time to go home... Pin
Nagy Vilmos10-Jul-12 3:26
professionalNagy Vilmos10-Jul-12 3:26 
GeneralRe: You know it's time to go home... Pin
spencepk10-Jul-12 7:36
spencepk10-Jul-12 7:36 
GeneralRe: You know it's time to go home... Pin
StM0n10-Jul-12 19:40
StM0n10-Jul-12 19:40 
GeneralRe: You know it's time to go home... Pin
SoMad10-Jul-12 11:51
professionalSoMad10-Jul-12 11:51 
GeneralRe: You know it's time to go home... Pin
henrikqwerty32125-Jul-12 14:52
henrikqwerty32125-Jul-12 14:52 
GeneralDictionary Misuse PinPopular
Martin Thwaites9-Jul-12 4:22
Martin Thwaites9-Jul-12 4:22 
GeneralRe: Dictionary Misuse Pin
Henning Dieterichs9-Jul-12 8:58
Henning Dieterichs9-Jul-12 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.