题解 | #计算日期到天数转换#
计算日期到天数转换
http://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
import java.util.*; import java.time.*; //日期操作全用java time包 public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNextInt()){ int year=sc.nextInt(); int month=sc.nextInt(); int day=sc.nextInt(); //Calendar c=Calendar.getInstance(); //c.set(year,month-1,day); //System.out.println(c.get(Calendar.DAY_OF_YEAR)); LocalDate ld=LocalDate.of(year,month,day); System.out.println(ld.getDayOfYear()); } } }