I have a problem with my month
public static void main(String[] args) {
GregorianCalendar tgl;
tgl = new GregorianCalendar ();
System.out.println("Tanggal Sekarang : " +
tgl.get (Calendar.DATE) + "/" +
tgl.get (Calendar.MONTH) + "/" +
tgl.get (Calendar.YEAR));
}
The result is :
Date now : 27/3/2013
Calendar.MONTH
is zero-based. So April will appear as3
.Instead, if you want to format a date use
SimpleDateFormat
and callgetTime()
on your calendar instance to get aDate
: