public static void main(String[] args) {
//2017-12-13
String str = "12-13";
//2017年每个月的天数
List<Integer> dayOfMon = Arrays.asList(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
int month = Integer.parseInt(str.split("-")[0]);
int day = Integer.parseInt(str.split("-")[1]);
int result = (month - 1) * dayOfMon.get(month - 1) + day;
System.out.println(str + " is the " + result + "th day of this year.");
}
Java-判断某日期为该年的第几天
最新推荐文章于 2023-02-27 15:06:30 发布