Today, If i run the program first time then create the object otherwise we use the previous object.
public class ObjectRestriction {
static SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
static String date = "00000000";
public static void main(String[] args) {
if( date.equals(formatter.format(new Date())))
{
System.out.println("already create object");
}
else
{
Reconcilation rc = new Reconcilation();
date = formatter.format(new Date());
System.out.println(date);
}
}
}
But when I run again then it initialize date variable to "00000000" and create new object. so, please help to restrict object creation on the basis of date.