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 3452158
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:13:28+00:00 2026-05-18T09:13:28+00:00

I am trying to build a map with time starting from 06.00 to 23:59

  • 0

I am trying to build a map with time starting from 06.00 to 23:59 as keys and I will keep track of a number for each time as value.I need the time to stored HH.mm as format and I am planning to build the map using a loop by incrementing one minute and run the following code inside the loop.The problem here is since I have to set the format as HH.MM strictly I have to get the input as String and format it and then parse it back as double which affects the perfomance.Is there a global setting to change so that whatever double number I choose in this particular class should be of the format ##.##.Also point here to note is since it is time it ends at 60 minutes and hence I have to break the current iteration with the help of .6.

    Map map = new LinkedHashMap();
    //Edit:Moved DecimalFormat Outside the loop
    DecimalFormat df = new DecimalFormat("##.##");
    for (double time= 06.00; time<= 22.00; time= time+ 01.00)
    {

        String timeString = df.format(appointmentTime);
        time = Double.parseDouble(timeString);

        if (timeString.indexOf(".6") != -1)
        {
            time= time+ 00.40;

        }
        map.put(time,"<number>");
    }
  • 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-18T09:13:29+00:00Added an answer on May 18, 2026 at 9:13 am

    I beliI believe you choose the most complicated approach. Instead of iterating the time variable you could iterate a simple number indicating the minutes since 0 o’clock and then generate your time double only for the map.

    for(int totalMinutes = 6 * 60; totalMinutes <= 22 * 60; totalMinutes ++) {
        map.put(buildTimeDouble(totalMinutes),”<number>”);
    }
    

    But I believe (I do not understand your question in that point), it would be better not to use a double for the map key, instead you could use your own Time class, something like:

    Time{
      private  int hour;
      private int minutes;
    
      public Time(int hour; int minutes) {
         this.hour = hour;
          this.minutes = minutes;
       }
    
       public toString(){
          return hour + “:” + minutes
       }
    
       public static Time fromTotalMinutes(int totalMinutesSinceZeroOclock){
          return new Time(totalMinutesSinceZeroOclock / 60; totalMinutesSinceZeroOclock / 60);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build render the raw data from a Quake 3 .map file
I am trying to build a map[string]map[string]string which will look something like this: {
We are now trying to build a map library like google/bing/yahoo,we will use it
I'm trying to build a simple Maps app based on the hello map tutorial
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build a method which returns the shortest path from one node to
I am new to android programming and trying to build a map activity app.
I am trying to build an interactive map using an imagemap and jquery. I
I am starting out with mongodb and having hard time trying to query nested
I'm trying to build a program that reads SMS from a specific sender. It

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.