如何在java中查找当前财政年度的余额天数。例如截至3月31日的余额日。
if(Integer.parseInt(currentmonth)<4){
currentyears=Integer.parseInt(currentyear)-1;
finMonth=Integer.parseInt(currentmonth)+9;
remainMonth=12-finMonth;
}else{
currentyears=Integer.parseInt(currentyear);
finMonth=Integer.parseInt(currentmonth)-3;
remainMonth=12-finMonth;
}
这是我查找财政年度的代码。我的问题是找到财政年度的剩余天数。
答案 0 :(得分:1)
这是让你入门的东西:
import java.util.Calendar;
public class DaysLeft {
public static void main(String args[]) {
Calendar cal = Calendar.getInstance();
int max_days = cal.getMaximum(Calendar.DAY_OF_YEAR);
int today = cal.get(Calendar.DAY_OF_YEAR);
int days_left = max_days - today;
System.out.format("We have a maximum of %d days this year.\n", max_days);
System.out.format("Today is day number %d.\n", today);
System.out.format("That means we have %d days left this year.\n",days_left);
}
}
它计算一年中的天数,今天的天数以及一年中剩余的天数。当然,您必须根据自己的需要进行调整。祝你好运!