Code example for Calendar

Methods: getTimeZone, setTimeInMillis

0
        public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction(); 
            if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)) { 
                String tz = intent.getStringExtra("time-zone"); 
                mCalendar = Calendar.getInstance(TimeZone.getTimeZone(tz)); 
                if (mClockFormat != null) { 
                    mClockFormat.setTimeZone(mCalendar.getTimeZone()); 
                } 
            } 
            updatePowerClock(); 
        } 
    }; 
 
    final void updatePowerClock() { 
        mCalendar.setTimeInMillis(System.currentTimeMillis());
        setTextColor(mClockColor);
        setText(getSmallTime());
    } 
 
    private final CharSequence getSmallTime() {
        boolean b24 = DateFormat.is24HourFormat(mContext);