SimpleDateFormat dsf = new SimpleDateFormat("yyyy-MM"); String date = dsf.format(new Date()); Calendar calendar = Calendar.getInstance();
时间: 2024-05-22 22:15:58 浏览: 81
java SimpleDateFormat &Calendar
This code creates a SimpleDateFormat object with the format "yyyy-MM", which represents the year and month in a specific pattern. It then formats the current date using this format and stores it in a String variable called "date". Finally, it creates a Calendar object and sets it to the current date and time using the getInstance() method.
阅读全文