public static int dayOfYear(String date) {
int day_count = 0;
StringBuffer str = new StringBuffer();
for(int i = 0;i < 4;i++){
char ch = date.charAt(i);
str.append(ch);
}
int year = Integer.parseInt(String.valueOf(str));
int[] days = new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};
//判断是否为闰年
//boolean isleap = false;
if(year %4 ==0 &&year%100!=0 ||year %400==0){
//isleap = true;
days[2] = 29;
}
StringBuffer str2 = new StringBuffer();
for(int i = 5;i<7;i++){
char ch = date.charAt(i);
str2.append(ch);
}
int month = Integer.parseInt(String.valueOf(str2));
if(month == 1 ){
for(int i = 2;i <= month;i++){
day_count += days[i];
}
} else {
for(int i = 1;i < month;i++){
day_count += days[i];
}
}
StringBuffer str3 = new StringBuffer();
for(int i = 8;i<10;i++){
char ch = date.charAt(i);
str3.append(ch);
}
int day = Integer.parseInt(String.valueOf(str3));
day_count += day;
return day_count;
}