Calendar c = Calendar.getInstance();
取得系統日期:year = c.get(Calendar.YEAR);
month = c.grt(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
取得系統時間:hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
如何比較時間
Calendar c = Calendar.getInstance();
c.set(Calendar.MONTH, Calendar.MARCH);
c.set(Calendar.DAY_OF_MONTH, 3);
long time2= c.getTimeInMillis();
c.set(Calendar.MONTH, Calendar.AUGUST);
c.set(Calendar.DAY_OF_MONTH, 8);
long time3= c.getTimeInMillis();
if(time>time2){
//Logic
if(time>time3){
//Logic
}
}
沒有留言:
張貼留言