String bookNo="1"; Date date=new Date(); SimpleDateFormat sdf1=new SimpleDateFormat("yyyyMMdd"); String times=sdf1.format(date); NumberFormat f= new DecimalFormat("000000"); if(!bookNo.equals("") && !bookNo.isEmpty()){ int count = Integer.parseInt(bookNo.substring(0)); bookNo = f.format(count+1); }else{ bookNo="000001"; }