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

  • Home
  • SEARCH
  • 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 3282256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:54:27+00:00 2026-05-17T19:54:27+00:00

When setting issue estimates in JIRA, you can enter a string like 1d 2h

  • 0

When setting issue estimates in JIRA, you can enter a string like "1d 2h 30m" and JIRA will translate this (I’m assuming) into a corresponding number of milliseconds.

Is there an available Java library that does this?

I’m using a Spring managed bean that takes a property indicating how often a directory ought to be purged, and I’d like to allow the configuration to take a human-readable string rather than an explicit number of milliseconds.

Alternatively, if there’s a better approach I’m not thinking of, I’d love to hear it.

  • 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-17T19:54:28+00:00Added an answer on May 17, 2026 at 7:54 pm

    The parser is not too complex:

    public static long parse(String input) {
       long result = 0;
       String number = "";
       for (int i = 0; i < input.length(); i++) {
         char c = input.charAt(i);
         if (Character.isDigit(c)) { 
           number += c; 
         } else if (Character.isLetter(c) && !number.isEmpty()) {
           result += convert(Integer.parseInt(number), c);
           number = "";
         }
       }
       return result;
    }
    
    private static long convert(int value, char unit) {
      switch(unit) {
        case 'd' : return value * 1000*60*60*24;
        case 'h' : return value * 1000*60*60;         
        case 'm' : return value * 1000*60;
        case 's' : return value * 1000;
      }
      return 0;
    }
    

    The code is pretty fault tolerant, it just ignores almost anything it can’t decode (and it ignores any whitspace, so it accepts “1d 1s”, “1s 1d”, “1d20m300s” and so on).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using asp.net with c#. My issue is this that I am setting
I'm having an issue setting up one of my projects in TeamCity (v4.0), specifically
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
I have an issue setting up an external tool in Visual Studio. The tool
I'm having a bit of an issue setting up our test site. In IIS
I am having an issue with setting the background-image of a #x to the
I am having a small issue in setting up speed tracer with ubuntu. any
We are using MSDTC for SQL transactions. I am having issue with setting up
I have a wierd hibernate related issue while setting a date field in an
So my issue is that I'm setting a message in a session var to

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.