get Current Time Color - Android Graphics

Android examples for Graphics:Color

Description

get Current Time Color

Demo Code


//package com.java2s;

import android.util.Log;
import java.util.Calendar;

public class Main {
    static String getCurrentTimeColor() {
        Calendar c = Calendar.getInstance();
        String hour = String.valueOf(c.get(Calendar.HOUR_OF_DAY));
        String min = String.valueOf(c.get(Calendar.MINUTE));
        String sec = String.valueOf(c.get(Calendar.SECOND));

        //Check if length is 1
        if (hour.length() < 2) {
            hour = "0" + hour;
        }//from   w ww.  j  av a 2s.  com
        if (min.length() < 2) {
            min = "0" + min;
        }
        if (sec.length() < 2) {
            sec = "0" + sec;
        }
        String time = hour + min + sec;
        Log.d("TIMECOLOR", time);
        return time;
    }
}

Related Tutorials