请原谅我,因为我是编码方面的初学者。我尝试研究将一些缺少的记录添加到列表中的方法,但似乎仍然无法正确地将其放入我的代码中。
我有两个具有不同结果集的ArrayList。说,第一个是通过其他方法派生并存储在abcList中。然后,此列表在我当前的fixChartStats方法中用作参数。
在我的代码中,我将检查abcList中的相应记录,以及从fixChartStats方法中的hql查询派生的第二个列表。
如果记录对应,那么我将执行如下所示的必要操作以更新ApprovedCount数字等,否则我将其设置为0。
我该如何添加我进入第一个arraylist(即abcList)的第二个列表中缺少的记录?这里有人可以说清楚吗?如果我的问题不清楚,请让我知道。预先感谢,伙计们!
private void fixChartStats(List<TAbcModel> abcList, Map<String, Object> param, List<IssueModel> issueList, List<DestModel> destList) throws Exception {
//initialize the hql query
//translate all fields from Object[] into individual variable
firstRow = true;
for (TAbcModel abc : abcList) {
if (abc.getId().getAbcYear() = abcYear &&
abc.getId().getAbcMonthId() = abcMonthId &&
abc.getId().getAbcApplAccnId().getAccnId().equalsIgnoreCase(abcApplAccnId.getAccnId()) {
if (firstRow) {
abc.setApprovedCount(abcApprovedCount);
abc.setCancelledCount(abcCancelledCount);
firstRow = false;
} else {
abc.setApprovedCount(0);
abc.setCancelledCount(0);
}
}else{
// How to do the necessary here
// Below is what I've tried
abcList.add(abc); …Run Code Online (Sandbox Code Playgroud) 如何循环年份和月份以显示以下输出?显示期间的限制是当前月份和年份。此外,显示3年(包括截至日期的年份)。表示如果现在显示2019,则显示2018和2017。
我尝试使用一些代码作为Java应用程序运行,以期获得下面的预期输出,但这就是我已经尝试并得到的。
如果有人可以在这里阐明一点,将不胜感激。
public class TestClass {
public static void main(String[] args) {
Calendar today = Calendar.getInstance();
//month=5, index starts from 0
int month = today.get(Calendar.MONTH);
//year=2019
int year = today.get(Calendar.YEAR);
for(int i = 0; i < 3; i++) { //year
for(int j= 0; j <= month; j++) { //month
System.out.println("Value of year: " + (year - 2)); //start from 2017 and iterate to 2 years ahead
System.out.println("Value of month: " + (month + 1)); //start from January (index val: …Run Code Online (Sandbox Code Playgroud)