Re: [J2SE] 求某年某月的當月天數?
== 恕刪 ==
根據你的程式做了一個小修改
import java.util.Calendar;
import java.util.Locale;
public class TestDate {
static Calendar c = Calendar.getInstance(Locale.TAIWAN);
public static void processDate(int year, int month) {
c.set(year, month - 1, 1);
int maxdays = c.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println(c.get(Calendar.YEAR));
System.out.println(c.get(Calendar.MONTH) + 1);
System.out.println(maxdays);
}
public static void main(String[] args) {
processDate(2007, 2);
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.167.72.2
→
08/30 23:34, , 1F
08/30 23:34, 1F
→
08/31 09:06, , 2F
08/31 09:06, 2F
討論串 (同標題文章)
完整討論串 (本文為第 3 之 5 篇):