get Time Millis As Hour And Minute and return long - Android java.util

Android examples for java.util:Time

Description

get Time Millis As Hour And Minute and return long

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static long getTimeMillisAsHourAndMinute(long millis) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(millis);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, minute);
        return calendar.getTimeInMillis();
    }//from   w ww. ja v  a 2s.  c  om
}

Related Tutorials