题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
import java.util.Calendar; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int y = in.nextInt(); int m = in.nextInt(); int d = in.nextInt(); Calendar c1 = Calendar.getInstance(); //实例化 c1.set(y, m - 1, d); //注意月份从0开始 System.out.println(c1.get(Calendar.DAY_OF_YEAR)); } }