共計 283 個字符,預(yù)計需要花費 1 分鐘才能閱讀完成。
在 Java 中,可以使用 java.time.LocalDate 類來獲得當(dāng)前的月份。下面是一個示例代碼:
import java.time.LocalDate;
public class Main {public static void main(String[] args) {LocalDate currentDate = LocalDate.now();
int currentMonth = currentDate.getMonthValue();
System.out.println(" 當(dāng)前月份:" + currentMonth);
}
}
運行以上代碼會輸出當(dāng)前的月份。
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!
正文完