Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个
DateFormat dateFormat = new SimpleDateFormat("MM"); Date date = new Date();
我知道值为 10,但不知道如何打印出来。如何将其转换为 int?如果有办法呢?
日期.getMonth()
它已被弃用-您应该使用日历,但如果您不想更改,那就可以了。它是 0 索引的,因此请记住适当地更改结果值。
Javadoc