public class Test { |
public static void main(String args[]) { |
Calendar c = Calendar.getInstance(); |
int year = c.get(Calendar.YEAR); |
int month = c.get(Calendar.MONTH); // |
注意:month特殊,是从 0 开始的, |
也就是 0 表示 1 月 |
int day = c.get(Calendar. |
DAY_OF_ |
MONTH); |
System.out.println( "现在是" +year+ "年" +(month+ 1 )+ "月" +day+ "日" ); |
} |
} //源代码片段来自云代码http://yuncode.net |
|