我正在创建一个项目来选择日期并在我选择另一个编辑文本想要计算的日期后加载到edittext中,并给出当前所选日期示例的下一个30天。
我创建了第一个并成功加载,我不知道如何在另一个Edittext中加载接下来的30天
COMPUTE W02-PAY-100S = W02-GROSS-PAY / 100
COMPUTE PAY = W02-GROSS-PAY - (W02-PAY-100S * 100)
COMPUTE W02-PAY-50S = PAY / 50
COMPUTE PAY = PAY - (W02-PAY-50S * 50)
COMPUTE W02-PAY-20S = PAY / 20
COMPUTE PAY = PAY - (W02-PAY-20S * 20)
COMPUTE W02-PAY-10S = PAY / 10
COMPUTE PAY = PAY - (W02-PAY-10S * 10)
COMPUTE W02-PAY-5S = PAY / 5
COMPUTE PAY = PAY - (W02-PAY-5S * 5)
COMPUTE W02-PAY-1S = PAY / 1
.
答案 0 :(得分:1)
您可以像这样设置日历对象
public Calendar getDate(int year, int month, int date) {
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.DAY_OF_MONTH, date);
calendar.set(Calendar.MONTH, month); // if Jan is 0
calendar.set(Calendar.YEAR, year);
calendar.add(Calendar.DATE, 30);
return calendar;
}
您可以从日历对象中获取日期,月份和年份
public String convertLongToDate(long date) {
Date convertedDate = new Date(date);
if (date < 86400000 * 1000L) {
convertedDate = new Date(date * 1000L);
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
simpleDateFormat.setTimeZone(TimeZone.getDefault());
return simpleDateFormat.format(convertedDate);
}
将上述方法称为
convertLongToDate(calendar.getTimeInMillis());