/**
* @param input
* <CURRENTMONTH><CURRENTMONTH+1>
* @return Month "MM"
*/
private String currentMonth(String input) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date now = new Date();
String temp = dateFormat.format(now);
String month = temp.split("/")[1];
input = input.toUpperCase();
if (input.length() == "<CURRENTMONTH>".length()) {
return month;
}
else if (input.length() > "<CURRENTMONTH>".length()) {
String math = input.substring("<CURRENTMONTH".length(),
"<CURRENTMONTH".length() + 1);
String value = input.substring(input.indexOf(math) + 1,
input.length() - 1);
int m = 0;
if (math.equals("+")) {
m = (Integer.parseInt(month) + Integer.parseInt(value)) % 12;
} else if (math.equals("-")) {
m = (Integer.parseInt(month) - Integer.parseInt(value)) % 12;
m = Math.abs(m);
} else {
return "Operator error!";
}
if (m == 0) {
m = 12;
}
if ((m + "").length() == 1) {
month = "0" + m;
} else {
month = m + "";
}
return month;
} else {
return "The format of input value " + input + " is incorrect.";
}
}