0

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"
      }  
  }
MSIslam
  • 4,587
  • 6
  • 25
  • 28
  • Which String values are remaining empty ? Are you sure your code is compiling? Because I see a lot of maybe typos over here. – Rahul Bobhate Jun 05 '13 at 18:17
  • 1
    Yeah, this won't run. Where's your actual code? – Reinstate Monica -- notmaynard Jun 05 '13 at 18:20
  • The beginlunch and endlunch Strings are empty in the format method. This is not the actual code. I am working on a huge project written by someone else. Almost 700-800 lines. I just tried to give a glipmse here how I am trying to work this out. Thanks. – MSIslam Jun 05 '13 at 18:32
  • Also, this is an android project. – MSIslam Jun 05 '13 at 18:33
  • Your issue can't be reproduced, because we only can guess how this could work. Post the execute() method and the calling order of the methods format(), execute() and this public X().... – Steve Benett Jun 05 '13 at 19:06
  • I actually figured out how to work with this. Using Adapter and making the outer class as adapter class solved the issue. I am sorry I didn't mention codes appropriately. Thanks all for the support. – MSIslam Jun 06 '13 at 14:55

1 Answers1

0

I actually figured out how to work with this. Using Adapter and making the outer class as adapter class solved the issue. I am sorry I didn't mention codes appropriately. Thanks all for the support.

MSIslam
  • 4,587
  • 6
  • 25
  • 28