Code example for Time

Methods: setToNowtoString

0
        outputStreamWriter.flush();
        outputStreamWriter.close();
    } 
 
    private String writeToGson(HashMap<String, String> info) { //convert device info to json
        Time now = new Time();
        now.setToNow();
        info.put("dateTime",now.toString());
        long uptime = SystemClock.elapsedRealtime();
        info.put("uptime",DateUtils.formatElapsedTime(uptime / 1000));
 
        Gson gson = new Gson();
        return gson.toJson(info);
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java