Java input year, month and day, and calculate the day of the year

From , 3 Years ago, written in Java, viewed 236 times.
URL https://pastebin.vip/view/13e5ebb0
  1. import java.util.*;  
  2. class WhichDay  
  3. {  
  4.     static void whichday(String date)  
  5.     {  
  6.         int days=0;  
  7.         String[] str1=date.split("年");  
  8.         int year=new Integer(str1[0]);  
  9.         String[] str2=str1[1].split("月");  
  10.         int month=new Integer(str2[0]);  
  11.         String[] str3=str2[1].split("日");  
  12.         int day=new Integer(str3[0]);  
  13.         int[] mdays=new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};  
  14.         if(year%4==0&&year%100!=0|year%400==0)  
  15.         mdays[2]=29;  
  16.         for(int i=1;i<=month-1;i++)  
  17.             days+=mdays[i];  
  18.         days+=day;  
  19.         System.out.println(days);  
  20.     }  
  21.     public static void main(String[] args)  
  22.     {  
  23.         Scanner sc=new Scanner(System.in);  
  24.         String date=sc.next();  
  25.         whichday(date);  
  26.     }  
  27. }  
  28. //java/7157

Reply to "Java input year, month and day, and calculate the day of the year"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website