I have declared some variables in outer class and trying to get the value of this variables from inner class and do some operation on this variables in a method in outer class. I am sharing here how I am trying to do it through some sample code. It's not working, the String
values remaining empty. I am doing some mistake or actually don't know how to do it. I am assuming outer class will get the updated value of a variable if it changed in inner class. Please help. I am not a very good programmer, so might be lacking basic knowledge. Thanks.
public class ABC
{
private String begin, end;
private SimpleDateFormat fromUser = new SimpleDateFormat("yyyy/MM/dd");
private SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd");
// Days in Current Month
public X()
{
new getDate(this).execute();
}
public format(){
String currdate = "2013/06/06"
try {
String reformattedbegin = myFormat.format(fromUser.parse(begin));
String reformattedend = myFormat.format(fromUser.parse(end));
Date begdate = myFormat.parse(reformattedbegin);
Date enddate = myFormat.parse(reformattedend);
Date currentdate = myFormat.parse(currdate);
if(currentdate.after(begdate) && currentdate.before(enddate))
System.out.println(enddate + "" + begindate + "" +currendate);
} catch (ParseException e) {
e.printStackTrace();
}
}
private class getdate
{
begin = "2013/06/05";
end = "2013/06/07"
}
}