在Java中,可以使用java.time.LocalDate
类来获得当前的月份。下面是一个示例代码:
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate currentDate = LocalDate.now();
int currentMonth = currentDate.getMonthValue();
System.out.println("当前月份:" + currentMonth);
}
}
运行以上代码会输出当前的月份。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:java怎么获得当前月