Kali ini, ane share ilmu yang baru saja ane dapet dari tugas yang diberikan oleh guru ane.
"Menampilkan waktu sekarang(yang ada di komputer)".
langsung aja ke code =>
import java.util.Calendar;
import java.util.GregorianCalendar;
class wektu {
public static void main(String[] args){
Calendar calendar = new GregorianCalendar();
String am_pm;
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
if(calendar.get(Calendar.AM_PM) == 0)
am_pm = "AM";
else
am_pm = "PM";
System.out.println("Current Time : " + hour + ":" + minute + ":" + second + " " + am_pm);
}
}
download contoh
Sumber
KEEP LEARNING!!!
Thursday, September 22, 2011 -
Java Moklet
0
comments
Menampilkan waktu saat ini (Curent Time) di Java
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment