getWakingtime from a spinner
<p>Hello I'd like to get the waking time of a person from spinners. I'd like to do the sleep calculator <a href="http://sleepyti.me/" rel="nofollow">http://sleepyti.me/</a> I have found Java methods on how to calculate the sleep cycles of a person, but since I'm very new to java and android programming, I don't know how to do it. </p>

<p>this is the code I found: </p>

<pre><code>    /** Date param for extra */
public static final String DATE_PARAM = "date";
/** Choice param for extra */
public static final String CHOICE_PARAM = "choice";

/**
   * Get times to wake. We add 14 minutes to fall asleep, and calculate the
   * sleep cycles.
   * 
   * @return list of times when to get up
   */
  public static Set&lt;Date&gt; getWakingTimes() {
    return getWakingTime(new Date());
  }

  /**
   * Get times to wake. We add 14 minutes to fall asleep, and calculate the
   * sleep cycles.
   * 
   * @param sleepTime
   *            bed time
   * 
   * @return list of times when to get up
   */

  public static Set&lt;Date&gt; getWakingTime( Date sleepTime ) {

    String l;  

    Calendar fallAsleep = Calendar.getInstance();
    fallAsleep.setTime( sleepTime );
    fallAsleep.add( Calendar.MINUTE, 14 );

    Set&lt;Date&gt; result = new TreeSet&lt;Date&gt;();

    for ( int i = 1; i &lt;= 6; i++ ) {
      fallAsleep.add( Calendar.MINUTE, 90 );
      result.add( fallAsleep.getTime() );
    }

    l = fallAsleep.getTime().toString();
    answer.setText( l );

    return result;


  }

  /**
   * Get sleeping times corresponding to a local time
   * 
   * @param wakingTime
   *            time to wake up !
   * @return list of times one should go to bed to
   */

  public static Set&lt;Date&gt; getSleepingTimes(Date wakingTime) {
Set&lt;Date&gt; result = new TreeSet&lt;Date&gt;();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime( wakingTime );
    calendar.add( Calendar.MINUTE, -14 );
    calendar.add( Calendar.MINUTE, -( 2 * 90 ) );
    for ( int i = 3; i &lt;= 6; i++ ) {
      calendar.add( Calendar.MINUTE, -90 );
      result.add( calendar.getTime() );
    }
    return result;

  } // end of getSleepingTimes method
</code></pre>

<p>This is so far what I have tried:</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.isleep);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.sleep32);

    // initializes controls
    initControls();
    // initializes arrayAdapter
    initArrayAdapter();



} // end of onCreate method

 private void initArrayAdapter()
 {

     ArrayAdapter&lt;String&gt; aa = new ArrayAdapter&lt;String&gt;( this,android.R.layout.simple_spinner_item, shour );
         aa.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
         sphr.setAdapter( aa );

     ArrayAdapter&lt;String&gt; aa2 = new ArrayAdapter&lt;String&gt;( this,android.R.layout.simple_spinner_item, sminute );
         aa2.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
         spmn.setAdapter( aa2 );

     ArrayAdapter&lt;String&gt; aa3 = new ArrayAdapter&lt;String&gt;( this,android.R.layout.simple_spinner_item, stime );
     aa3.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
         sptm.setAdapter( aa3 );

 }


private void initControls(){

    //timepicker = (TimePicker) findViewById (R.id.timePickerSleep);
    sphr = (Spinner) findViewById (R.id.spinner1);
    spmn = (Spinner) findViewById (R.id.spinner2);
    sptm = (Spinner) findViewById (R.id.spinner3);
    calculate = (Button) findViewById (R.id.btSleepCalculate);
    cancel = (Button) findViewById (R.id.btSleepCancel);
    answer = (TextView) findViewById (R.id.tvSleepResult);

    // providing listeners for each timepicker
    //timepicker.setIs24HourView( false );
    sphr.setOnItemSelectedListener(this);
    spmn.setOnItemSelectedListener(this);
    sptm.setOnItemSelectedListener(this);

    // providing listener for button
    calculate.setOnClickListener(this);
    cancel.setOnClickListener(this);

} // end of initControls method


public void onClick(View v) {
    // TODO Auto-generated method stub

    switch( v.getId() )
    {
    case R.id.btSleepCalculate:
        /*Toast.makeText(getBaseContext(), "Time selected: " 
                + timepicker.getCurrentHour() + ":" 
                + timepicker.getCurrentMinute(), Toast.LENGTH_LONG).show();
        calculateSleepTime();*/
        break;
    case R.id.btSleepCancel:

        break;
    } // end of switch statement

} // end of onClick method
</code></pre>

<p>As you can see, it doesn't have a method to calculate the sleep cycle. Please teach me where to put getWakingTime in my android code. I'm still stuck with this problem :( I don't know how to solve. Please help The result of the waking time should be displayed in the textview. Thanks.</p>

<p>P.S. This is my UI <a href="http://i50.tinypic.com/i6zhih.png" rel="nofollow">http://i50.tinypic.com/i6zhih.png</a></p>
