I am trying to create a coupon in following format :
{month} / {date} / {serialNumber}
I am selecting month and date from UI, so I am getting month and date properly but my problem is :
serialNumber should auto Increment and
It should again start from zero for a new date
what i tried is :
private static Integer srNumber = 000;
public Coupon CouponCreation(Coupon coupon) {
String voucherNumber;
srNumber += srNumber + 001;
voucherNumber = (coupon.getTransactionDate().getMonth() + 1)
+ "/" + coupon.getTransactionDate().getDate()
+ "/" + srNumber;
coupon.setVoucherNumber(voucherNumber);
return coupon;
}
Class Coupon contains all getter and setter methods
In above code I want to generate srNumber like: 001, 002, 003 and so on
But if coupon.getTransactionDate().getDate()
changed then srNumber will start again from 001, 002 and voucher number should be
08/02/001, 08/02/002 and so on