起首运用日历类,然后运用它的要领猎取当前月份
package test; import java.util.Calendar; public class Test { public static void main(String[] args) { Calendar cal=Calendar.getInstance();//运用日历类 int month=cal.get(Calendar.MONTH)+1;//取得月,由于从0最先的,所以要加1 System.out.println("当前月份:"+month); } }
效果:
当前月份:5
以上就是java中怎样取得当前月的细致内容,更多请关注ki4网别的相干文章!