Converting minutes to 24 hour format android application
<p>I need in my application to convert minutes to 24 hour formart, for example my app has a method that
return a time in minutes 260, how can I convert this time to 24 format?</p>

<p>thanks so much ,,</p>

<p>--- After upadting ----------------------------------------------------------------------</p>

<pre><code>//Inside OnCreate Method

//For Time Part#1
CaseDurationH.setOnItemSelectedListener(new OnItemSelectedListener() {

             public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {

                 int i = CaseDurationH.getSelectedItemPosition();
                 strH = parent.getSelectedItem().toString();

                 try { 
                  intH = Integer.parseInt(strH); 
                  intHInMin=intH*60; // inH and intHInMin are a integer
                } catch (NumberFormatException nfe) { 

                } 


                 if(i==2){

                     CaseDurationM.setEnabled(false);

                 }

                 if(strH.equals("hr0"))

                         {

                 CaseDurationM.setEnabled(true);

                     }



                 if(strH.equals("hr1"))

                         {

                 CaseDurationM.setEnabled(true);

                     }





                 if(strH.equals("hr2"))

                         {

                     CaseDurationM.setEnabled(false);  

                     }


             }

             public void onNothingSelected(AdapterView&lt;?&gt; arg0) {

                 // TODO Auto-generated method stub



             } });

//For Time Part#2
        CaseDurationM.setOnItemSelectedListener(new OnItemSelectedListener() {

             public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {

                 int i = CaseDurationM.getSelectedItemPosition();
                 strM = parent.getSelectedItem().toString();


                 try { 
                      intM = Integer.parseInt(strM); 

                    } catch (NumberFormatException nfe) { 

                    } 





             }

             public void onNothingSelected(AdapterView&lt;?&gt; arg0) {

                 // TODO Auto-generated method stub



             } });

  String CaseTime= calc();
  case1.setTime(CaseTime); //case1 is an Onbject 



//Out OnCreate Method
private String calc() {

                      int CTimeTotalInMin= intHInMin + intM;
          Calendar calendar = new GregorianCalendar();

          int CurrentHour = calendar.get(Calendar.HOUR);
          int CurrentMinute = calendar.get(Calendar.MINUTE);
          int CurrentTime= (CurrentHour * 60)+ CurrentMinute;
          int TotalTimeInMin= CurrentTime-CTimeTotalInMin;
          int hours = TotalTimeInMin / 60; 
          int minutes = TotalTimeInMin % 60;  
          if(hours&gt;23) 
             hours = hours % 24; 

       String g = ""+hours+":"+minutes;



         return g;}
</code></pre>

<hr>

<p>my problem is: How can I  get the (current Time - the time selected by the user from the Spinner 
(I show the user two lists for hours ( 0h or 1h or 2h) and Minutes ( from 0-59) as shown below,
for instant, if the user select (1 hour ) and the current time is (2:15 PM) the answer should be= 13:15 PM), I tried this code but it couldn't differ from PM and AM ?
any Suggestion ? thanks alot... </p>

<pre><code>&lt;!-- @ string.xml these imtes for CDurationH= hours --&gt;
    &lt;string name="hr0"&gt;0&lt;/string&gt;  
    &lt;string name="hr1"&gt;1&lt;/string&gt;  
    &lt;string name="hr2"&gt;2&lt;/string&gt; 
&lt;!-- @ string.xml these imtes for CDurationM= minutes --&gt; 
    &lt;string name="min0"&gt;0&lt;/string&gt; 
    &lt;string name="min5"&gt;5&lt;/string&gt; 
    &lt;string name="min10"&gt;10&lt;/string&gt;  
    &lt;string name="min15"&gt;15&lt;/string&gt; 
    &lt;string name="min20"&gt;20&lt;/string&gt;  
    &lt;string name="min25"&gt;25&lt;/string&gt;  
    &lt;string name="min30"&gt;30&lt;/string&gt; 
    &lt;string name="min35"&gt;35&lt;/string&gt;  
    &lt;string name="min40"&gt;40&lt;/string&gt;  
    &lt;string name="min45"&gt;45&lt;/string&gt; 
    &lt;string name="min50"&gt;50&lt;/string&gt;  
    &lt;string name="min55"&gt;55&lt;/string&gt;  
    &lt;string name="min59"&gt;59&lt;/string&gt; 
</code></pre>

<hr>
