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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:41:09+00:00 2026-06-12T01:41:09+00:00

This might be a dumb question, but let’s say I have a variable seconds

  • 0

This might be a dumb question, but let’s say I have a variable seconds in my JSP page and its value is 779. Now I want to convert it into minutes and seconds by doing the following:

    <c:set var="${seconds / 60}" value="min"/>
    <c:set var="${seconds mod 60}" value="sec">

This way I get min = 12.983333 and sec = 59.0.

Now I want to merge the two and display the result as 12:59. The problem I am facing is that min keeps getting rounded up to 13. I have tried many things, such as:

    <fmt:parseNumber var="minutes" integerOnly="true" type="number" value="${min}" />

    <fmt:formatNumber type="number" pattern="###" value="${min}" var="minutes" />

    fn:substringBefore(min, '.')

    maxFractionDigits="0"

    // and so on...

But all of them just return 13 consistently. I am a bit clueless at this point. But I may have missed something. I hope someone here has an idea, or a hint, about what might be wrong.

-edit

The code below made it work in the end. I have no clue what was wrong, since its also working with “/” now. Maybe some minor mistake elsewhere. Nevertheless thanks a lot for your time 🙂 Kudos!

    <c:set var="min" value="${fn:substringBefore((seconds div 60), '.')}"/>  
    <fmt:formatNumber var="sec" pattern="##" value="${seconds mod 60)}"/>   
  • 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-06-12T01:41:10+00:00Added an answer on June 12, 2026 at 1:41 am

    This (below) should be the only safe way to do it. pattern=”##” is not well supported, minIntegerDigits=”2″ is easier and cleaner.

    <c:set var="minutes" value="${fn:substringBefore(seconds div 60, '.')}"/> 
    <fmt:formatNumber var="seconds" minIntegerDigits="2" value="${ seconds - (minutes*60) }"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might sound like a reaaaally dumb question but... why do browsers have a
This might be a dumb question, but I don't get it: I have a
I know this might sound like a dumb question, but I have looked every
This might be a dumb question but I have not find the answer when
This might be a dumb question. But does ADO.net support updating to a database
Ok, this might just be a dumb question, but I was wondering if Bluetooth
This might be a dumb question. Sorry if it is. But Im working on
Ok so this might be a dumb question, but I can't seem to figure
This might seem like a really dumb question, but I am writing an application
This might sound very dumb question but I am just confused. I am quite

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.