|
Java學习者论坛
package org.yj.demo11.datedemo;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class DateDemo02 {
public static void main(String[] args) {
Calendar calendar=null;
calendar=new GregorianCalendar();
System.out.println("年:"+calendar.get(Calendar.YEAR));
System.out.println("月:"+(calendar.get(Calendar.MONTH)+1));
System.out.println("日:"+calendar.get(Calendar.DAY_OF_MONTH));
System.out.println("時:"+calendar.get(Calendar.HOUR_OF_DAY));
System.out.println("分:"+calendar.get(Calendar.MINUTE));
System.out.println("秒:"+calendar.get(Calendar.SECOND));
System.out.println("毫秒:"+calendar.get(Calendar.MILLISECOND));
}
}
各位大侠好,请问 System.out.println("月:"+(calendar.get(Calendar.MONTH)+1));
中为什么要在calendar后加1并且在外加个()号?谢谢答疑
歡迎来到Java学习者论坛,转载请注明地址:http://www.javaxxz.com. |
|