0
美好的一天,親愛的同事Java或SQL在數組中添加缺失的月份
你能幫助我嗎?我找不到決定。我從MySQL獲得數組,看起來像(數量和月):
[2, 07.16, 3, 08.16, 2, 10.16, 1, 11.16, 1, 12.16, 1, 01.17]
,我需要補充一點,在這個週期內錯過了0個月。對於此陣應增加08.16後0和09.16,因此成爲的樣子:
[2, 07.16, 3, 08.16, 0, 09.16, 2, 10.16, 1, 11.16, 1, 12.16, 1, 01.17]
將成爲任何意見感謝!
PS。我tryed做這樣的事情在Java中:
for (int i = objArrayOfCalulatedRisks.length; i > 3; i = i - 2) {
String dayMonthAndYear = objArrayOfCalulatedRisks[i].toString();
StringBuilder sb = new StringBuilder();
sb.append(dayMonthAndYear.charAt(3));
sb.append(dayMonthAndYear.charAt(4));
String rightMonth = sb.toString();
String dayMonthAndYear2 = objArrayOfCalulatedRisks[i-2].toString();
StringBuilder sb2 = new StringBuilder();
sb2.append(dayMonthAndYear.charAt(3));
sb2.append(dayMonthAndYear.charAt(4));
String leftMonth = sb2.toString();
int rightM = Integer.parseInt(rightMonth);
int leftM = Integer.parseInt(leftMonth);
if (leftM + 1 != rightM) {
}
非常感謝!我將使用Java決策,它更適合我的任務。 –