wsharba / opendatakit

Automatically exported from code.google.com/p/opendatakit
0 stars 1 forks source link

Briefcase is not respecting the daylight savings time offset when exporting (date-) time fields. #1074

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Fill up a form that will include "07:00:00.000Z" in some time field.
2. Export the data from the Briefcase using a computer that is (for example) in 
EET time zone (+2) and the current date is such that it also has one hour 
offset for daylight saving.   

What is the expected output? What do you see instead?
The expected output is "10:00 AM" but the actual output is "09:00". 

What version of the product are you using? On what operating system?
Any Briefcase under JRE 6. 

Please provide any additional information below.
The problem is lying under the getDate() function inside DateUtils.java 
(JavaRosa):

    public static Date getDate (DateFields f, String timezone) {
        Calendar cd = Calendar.getInstance();
        if(timezone != null) {
            cd.setTimeZone(TimeZone.getTimeZone(timezone));
        }
        cd.set(Calendar.YEAR, f.year);
        cd.set(Calendar.MONTH, f.month - MONTH_OFFSET);
        cd.set(Calendar.DAY_OF_MONTH, f.day);
        cd.set(Calendar.HOUR_OF_DAY, f.hour);
        cd.set(Calendar.MINUTE, f.minute);
        cd.set(Calendar.SECOND, f.second);
        cd.set(Calendar.MILLISECOND, f.secTicks);

        return cd.getTime();
    }

According to the following JDK bug, the "set()" method is clearing the DST 
information. The workaround is to use "add()" instead:

https://bugs.openjdk.java.net/browse/JDK-6615045?focusedCommentId=13327706&page=
com.atlassian.jira.plugin.system.issuetabpanels%3acomment-tabpanel#comment-13327
706

Original issue reported on code.google.com by mele...@surveycto.com on 17 Oct 2014 at 11:12