Click here to Skip to main content
15,569,547 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 1:44
BobJanova11-Jul-12 1:44 
GeneralRe: RateOfInterest... Pin
PIEBALDconsult11-Jul-12 4:50
professionalPIEBALDconsult11-Jul-12 4:50 
GeneralRe: RateOfInterest... Pin
BobJanova11-Jul-12 5:38
BobJanova11-Jul-12 5:38 
GeneralRe: RateOfInterest... Pin
Sandeep Mewara11-Jul-12 8:14
mveSandeep Mewara11-Jul-12 8:14 
GeneralRe: RateOfInterest... Pin
PIEBALDconsult11-Jul-12 9:37
professionalPIEBALDconsult11-Jul-12 9:37 
JokeRe: RateOfInterest... Pin
S Houghtelin10-Jul-12 12:21
professionalS Houghtelin10-Jul-12 12:21 
GeneralRe: RateOfInterest... Pin
greldak10-Jul-12 23:07
greldak10-Jul-12 23:07 
GeneralDating PinPopular
V.10-Jul-12 4:56
professionalV.10-Jul-12 4: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 14:57
professionalBrisingr Aerowing10-Jul-12 14:57 
GeneralRe: Dating Pin
Peter_in_278010-Jul-12 15:13
professionalPeter_in_278010-Jul-12 15:13 
GeneralRe: Dating Pin
V.11-Jul-12 10:14
professionalV.11-Jul-12 10:14 
GeneralRe: Dating Pin
jschell11-Jul-12 9:09
jschell11-Jul-12 9:09 
JokeRe: Dating Pin
walterhevedeich10-Jul-12 20:26
professionalwalterhevedeich10-Jul-12 20:26 
GeneralRe: Dating Pin
BobJanova11-Jul-12 5:38
BobJanova11-Jul-12 5:38 
GeneralRe: Dating Pin
Andrei Straut11-Jul-12 7:19
Andrei Straut11-Jul-12 7:19 
GeneralRe: Dating Pin
UNCRushFan15-Jul-12 13:46
UNCRushFan15-Jul-12 13:46 
GeneralRe: Dating Pin
jschell11-Jul-12 9:11
jschell11-Jul-12 9:11 
GeneralYou know it's time to go home... Pin
StM0n10-Jul-12 3:59
StM0n10-Jul-12 3:59 
GeneralRe: You know it's time to go home... Pin
Nagy Vilmos10-Jul-12 4:26
professionalNagy Vilmos10-Jul-12 4:26 
GeneralRe: You know it's time to go home... Pin
spencepk10-Jul-12 8:36
spencepk10-Jul-12 8:36 
GeneralRe: You know it's time to go home... Pin
StM0n10-Jul-12 20:40
StM0n10-Jul-12 20:40 
GeneralRe: You know it's time to go home... Pin
SoMad10-Jul-12 12:51
professionalSoMad10-Jul-12 12:51 
GeneralRe: You know it's time to go home... Pin
henrikqwerty32125-Jul-12 15:52
henrikqwerty32125-Jul-12 15:52 
GeneralDictionary Misuse Pin
Martin Thwaites9-Jul-12 5:22
Martin Thwaites9-Jul-12 5:22 
GeneralRe: Dictionary Misuse Pin
Henning Dieterichs9-Jul-12 9:58
Henning Dieterichs9-Jul-12 9: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.