Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:04:59+00:00 2026-05-30T17:04:59+00:00

I need in my application to convert minutes to 24 hour formart, for example

  • 0

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?

thanks so much ,,

— After upadting ———————————————————————-

//Inside OnCreate Method

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

             public void onItemSelected(AdapterView<?> 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<?> arg0) {

                 // TODO Auto-generated method stub



             } });

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

             public void onItemSelected(AdapterView<?> 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<?> 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>23) 
             hours = hours % 24; 

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



         return g;}

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…

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:05:01+00:00Added an answer on May 30, 2026 at 5:05 pm

    Calculate hour and minute values via division and modulus operators.
    Check for possible hour values greater than 23 indicating exceed of a daytime.
    Format your values to represent as 24 hour format:

    int minutes = 260;
    int hours = minutes / 60;
    int minutesInDisplay = minutes % 60;
    if (hours > 23)
        hours = hours % 24;
    String postfix = (hours < 12) ? "am" : "pm";
    NumberFormat formatter = new DecimalFormat("00");
    String display = formatter.format(hours) + ":"
            + formatter.format(minutesInDisplay);
    System.out.println("24 hour formatted time: " + display + " " + postfix);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a library for my ASP.NET MVC3 Application that can convert to and
I need to convert my WPF application, which has a Ribbon , to use
i have an application that has a dependancy on gdiplus. i need the application
I need to convert text file to XML file through C# application. Can any
i need to create an application in java that would convert text strings into
I am writting a VB.Net application. I need to be able to convert either
I writing simple application that need to make some record of the incoming sound.
I've been working in a time attendance application and need some enlightment. This is
IN converting over a legacy application we need to convert named query to nhibernate.
I need to convert an XPS file I create with my application to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.