题解 | #计算日期到天数转换#
计算日期到天数转换
http://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
用Calendar类
import java.util.Scanner;
public class Main {
//HJ73 计算日期到天数转换
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int y =sc.nextInt();
int m =sc.nextInt();
int d = sc.nextInt();
Calendar calendar = Calendar.getInstance();
//.set()方法中 month 范围为0-11 对应1-12月
calendar.set(y,m-1,d);
System.out.println(calendar.get(Calendar.DAY_OF_YEAR));
}
}