✔ 最佳答案
The Time class has many deprecated methods, which do not include one to extract minutes.
The Calendar abstract class is generally used for time calcualtions. Here are some examples of its use. If you want to have just the minutes and not hours, you can create your own class for that purpose. The examples below include one which extracts the current minute as an int.
If you need more info, PM or post supplementary questions.
import java.util.Calendar;
import java.sql.Time;
public class TestTime
{
public static void setTime(Calendar cal, int hour, int min)
{
cal.set(cal.HOUR_OF_DAY,hour);
cal.set(cal.MINUTE,min);
}
public static int getMinute(Calendar cal)
{
return cal.get(Calendar.MINUTE);
}
public static void main(String[] args)
{
Calendar now=Calendar.getInstance();
System.out.printf("Minutes=%d\n",now.get(Calendar.MINUTE));
// Time abc=new Time(23,59,0);
Calendar abc=Calendar.getInstance();
setTime(abc,23,59);
System.out.printf("Minutes=%d\n",abc.get(Calendar.MINUTE));
System.out.printf("Minutes=%d\n",getMinute(abc));
}
}