BÀI 21 - CALENDAR TRONG LẬP TRÌNH ANDROID
Video bài học
Truy suất thời gian trong android ta gọi hàm:
//Library java.util
Calendar calendar = Calendar.getIntance();
textView.append(calendar.getTime() + "\n");
textView.append(calendar.get(Calendar.DATE) + "\n");
textView.append(calendar.get(Calendar.MONTH) + "\n");
textView.append(calendar.get(Calendar.YEAR) + "\n");
// Định dạng ngày tháng năm...
SimpleDateFormat dinhdangngay = new SimpleDateFormat("dd/MM/yyyy") ;
textView.append(dinhdangngay.format(calendar.getTime()) + "/n");
textView.append(calendar.get(Calendar.HOUR) + "\n");
textView.append(calendar.get(Calendar.HOUR_OF_DAY) + "\n");
SimpleDateFormat dinhdanggio = new SimpleDateFormat("hh:mm:ss a");
textView.append(dinhdanggio.format(calendar.getTime()) + "/n");
//Search google: android simpledateformat