Berikut adalah contoh untuk membuat tampilan bulan dalam bahasa Indonesia seperti "Januari, Februari, Maret ... " menggunakan class java calender, oke berikut contoh programnya
Nama file: contoh_Calender_Indonesia.java
import java.util.Calendar;
public class contoh_CalenderIndonesia {
public static void main(String[] args) {
//create Calendar instance
Calendar now = Calendar.getInstance();
System.out.println("Sekarang Tanggal : " + now.get(Calendar.DATE)
+ "-"
+ (now.get(Calendar.MONTH) + 1)
+ "-"
+ now.get(Calendar.YEAR));
//create an array of months
String[] strMonths = new String[]{
"Januari",
"Februari",
"Maret",
"April",
"Mei",
"Juni",
"Juli",
"Agustus",
"September",
"oktober",
"November",
"Desember"
};
System.out.println("Sekarang Bulan : " +
strMonths[now.get(Calendar.MONTH)]
);
}
}
Output
run:
Sekarang Tanggal : 31-7-2016
Sekarang Bulan : Juli
BUILD SUCCESSFUL (total time: 0 seconds)
Selamat mencoba, semoga bermanfaat ...
No comments:
Post a Comment