I want to fetch the values from a textfield and then increment it by one. My problem is that the value which I will fetch also contain some text at beginig for eg: SBI20132012000 I need to fetch the last 3 digits and want to increment it by 1.
package myproj.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import myproj.DATAENTRY;
public class CalendarUtil {
private static String lastUsedDatePrefix = "";
public static int counter = 0;
public String getRemId() {
final String datePrefix = new SimpleDateFormat("yyyyMMdd").format(new Date());
if (lastUsedDatePrefix.equals(datePrefix)) {
DATAENTRY dt = new DATAENTRY();
String text = dt.tf_rm_id.getText().substring(8);// get the value from textfield and increment it
int text1=Integer.parseInt(text);
counter=text1;
CalendarUtil.counter++;
} else {
CalendarUtil.lastUsedDatePrefix = datePrefix;
CalendarUtil.counter = 1;
}
final String counterSuffix = ((100 <= CalendarUtil.counter) ? "" : (10 <= CalendarUtil.counter) ? "0" : "00") + CalendarUtil.counter;
return datePrefix + counterSuffix;
}
}