title: String time passed from AsyncTask class variable not converting into date object in android but it works fine when i hard code the sting
body: <p>String time passed from <code>AsyncTask</code> class variable not converting into date object in android but it works fine when i hard code the string. </p>
  
  <pre><code> public class Main2Activity extends AppCompatActivity {
          String getdate, getday, gethijri, gettimezone, getfajr, getsunrise, getduhr, getasr, getsunset, getmaghrib, getisha, getimsak;
          public static final String inputFormat = "hh:mm";
          SimpleDateFormat inputParser = new SimpleDateFormat(inputFormat);
          String compareFajrOne = "";
          String compareFajrTwo = "";
          private Date date;
          private Date dateComparefajrOne;
          private Date dateComparefajrTwo;
          private Date dateCompareishaTwo;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dailynamazrecord);
    Button  fajrofer = (Button) findViewById(R.id.fajrada);
      final boolean[] ispressed = {false};
      Calendar now = Calendar.getInstance();
       final int hour = now.get(Calendar.HOUR);
      final int minute = now.get(Calendar.MINUTE);
  
      date = parseDateeb(Integer.toString(hour)+":"+ Integer.toString(minute));
      dateComparefajrOne = parseDateeb(compareFajrOne);
      dateComparefajrTwo = parseDateeb(compareFajrTwo);
      fajrofer.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              Toast.makeText(mContext, compareFajrOne+"\n"+compareFajrTwo+"\n"+dateComparefajrOne+"\n"+date+"\n"+dateComparefajrTwo, Toast.LENGTH_LONG).show();
              if ( dateComparefajrOne.before(date)&amp;&amp; dateComparefajrTwo.after(date)) {
  
                  if (ispressed[0]) {
                      fajrofer.setBackgroundResource(R.drawable.namazoffered);
  
                  } else {
                      fajrofer.setBackgroundResource(R.drawable.ofeer);
                  }
  
                  ispressed[0] = !ispressed[0];
              } else {
                  if (p != null)
                      showPopup(Main2Activity.this, p);
              }
  
  
          }
  
  
      });
  
  public class FectchDetails2 extends AsyncTask&lt;String, String, String&gt; {
      String data = "";
  
  
      @Override
      protected String doInBackground(String... params) {
          URL url = null;
          try {
              url = new URL("http://api.aladhan.com/v1/timingsByCity?city=Karachi&amp;country=Pakistan&amp;method=8");
              HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
              InputStream inputStream = urlConnection.getInputStream();
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
              String line = "";
              while (line != null) {
                  line = bufferedReader.readLine();
                  data = data + line;
              }
  
              JSONObject json = new JSONObject(data);
              JSONObject gtimings=json2.getJSONObject("timings");
              getfajr = gtimings.getString("Fajr");
              getsunrise = gtimings.getString("Sunrise");
              getduhr = gtimings.getString("Dhuhr");
              getasr = gtimings.getString("Asr");
              getsunset = gtimings.getString("Sunset");
              getmaghrib = gtimings.getString("Maghrib");
              getisha = gtimings.getString("Isha");
              getimsak = gtimings.getString("Imsak");
  
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
  
          return null;
      }
  
      @Override
      protected void onPostExecute(String s) {
          super.onPostExecute(s);
  
          compareStringOne=getfajr.toString();
          compareStringTwo=getsunrise.toString();
  
      }
  }
  
  
  
  
  private Date parseDateeb(String date) {
  
      try {
  
          return   inputParser.parse(date);
      } catch (java.text.ParseException e) {
          return new Date(0);
      }
  
  }
  }
  </code></pre>
  
  <p>String time passed from <code>AsyncTask</code> class variable not converting into date object in android but it works fine when i hard code the sting.
  like:
  <code>String compareFajrOne = "05:18";</code>
  <code>String compareFajrTwo = "06:40";</code>
  Kindly guide me i just want to check that current time is in the range of given times</p>