Code example for Time

Methods: formatsetsetToNowtoMillis

     * Get the string of the alarm ring time 
     * @param napDuration 
     * @return 
    private String formatAlarmTime(int napDuration) {
        Time t = new Time();
        t.set(t.toMillis(false) +napDuration);
        return t.format("%H:%M");
     * Save the configured nap duration in shared preferences 
     * @param appWidgetId The widget id 
     * @param napDuration The duration in minutes 
    static void setNapDuration(Context context, int appWidgetId, int napDuration) {
        SharedPreferences.Editor prefs = context.getSharedPreferences(PREFS_NAME, 0).edit();
        prefs.putInt(PREF_DURATION_PREFIX + appWidgetId, napDuration);
Connect your IDE to all the code out there  Get Codota for Java