import java.util.*;
public class HelloDate
{
public static void main(String[] args)
{
Calendar c = new GregorianCalendar();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH) + 1;
int day = c.get(Calendar.DAY_OF_MONTH);
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
String dayOfWeekStr = null;
switch(dayOfWeek)
{
case 1:
dayOfWeekStr = "星期日"; break;
case 2:
dayOfWeekStr = "星期一"; break;
case 3:
dayOfWeekStr = "星期二"; break;
case 4:
dayOfWeekStr = "星期三"; break;
case 5:
dayOfWeekStr = "星期四"; break;
case 6:
dayOfWeekStr = "星期五"; break;
case 7:
dayOfWeekStr = "星期六"; break;
}
int hour24 = c.get(Calendar.HOUR_OF_DAY);
int min = c.get(Calendar.MINUTE);
int sec = c.get(Calendar.SECOND);
String hour24Str = null;
String minStr = null;
String secStr = null;
if(hour24/10 == 0)
hour24Str = "0" + new Integer(hour24).toString();
else
hour24Str = new Integer(hour24).toString();
if(min/10 == 0)
minStr = "0" + new Integer(min).toString();
else
minStr = new Integer(min).toString();
if(sec/10 == 0)
secStr = "0" + new Integer(sec).toString();
else
secStr = new Integer(sec).toString();
String currentDate = new String(year + "年" + month + "月" + day + "日" + "
" +
dayOfWeekStr);
String currentTime = new String(hour24Str + ":" + minStr + ":" + secStr);
System.out.println("当前日期为: " + currentDate);
System.out.println("当前时间为: " + currentTime);
}
}