ArmandasRokas / beeware

0 stars 0 forks source link

Timezones #87

Open ArmandasRokas opened 4 years ago

ArmandasRokas commented 4 years ago

The app does not work correctly when the user is not at the same timezone as the subscribed hives

        System.out.println("Curr: " + System.currentTimeMillis());
        Calendar cal = Calendar.getInstance();
        TimeZone cphTimeZone = TimeZone.getTimeZone("Europe/Copenhagen");
        Log.d("getDisplayName", cphTimeZone.getDisplayName());
//        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//        sdf.setTimeZone(tz);
        Log.d("Current time ", cal.getTime()+"");
        Timestamp timestamp = new Timestamp(cal.getTime().getTime());
        cal.setTime(new Date(timestamp.getTime()));
        Log.d("CurrTime time stamp", cal.getTime()+"");
        Timestamp currTimeMillis =new Timestamp(System.currentTimeMillis());
        cal.setTime(new Date(currTimeMillis.getTime()));
        Log.d("currentTimeMillis", currTimeMillis.toString()+"");

        /* print your timestamp and double check it's the date you expect */
//        long timestamp = cursor.getLong(columnIndex);
//        String localTime = sdf.format(new Date(timestamp * 1000)); // I assume your timestamp is in seconds and you're converting to milliseconds?
//        Log.d("Time: ", localTime);
        //cal.setTimeZone(set);
        //TimeZone tz = cal.getTimeZone();
ArmandasRokas commented 4 years ago

Possible solution: