get Today At hour and minute - Android java.util

Android examples for java.util:Calendar

Description

get Today At hour and minute

Demo Code

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

public class Main{

    public static Calendar getTodayAt(int hours, int minutes) {
        Calendar today = Calendar.getInstance();
        Calendar cal = Calendar.getInstance();
        cal.clear();//  w w  w.  j ava2 s .c  o m

        int year = today.get(Calendar.YEAR);
        int month = today.get(Calendar.MONTH);
        //represents the day of the month
        int day = today.get(Calendar.DATE);
        cal.set(year, month, day, hours, minutes, 0);
        return cal;
    }

}

Related Tutorials