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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:28:36+00:00 2026-05-30T18:28:36+00:00

I have a jspinner in the format yyyy-MM-dd hh:mm:ss . The problem is the

  • 0

I have a jspinner in the format yyyy-MM-dd hh:mm:ss. The problem is the spinner ‘hh’ only goes up to value ’12’. How can i make it so it goes up to 24 hours?

  • 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-30T18:28:37+00:00Added an answer on May 30, 2026 at 6:28 pm

    you have define for two things for JSpinner (basically contents of the tutorial fully answering your question)

    • SimpleDateFormat

    • SpinnerDateModel

    for example

    import java.awt.*;
    import java.text.SimpleDateFormat;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    
    public class TimeZoneSpinners {
    
        private final String[] zones = {"Asia/Tokyo", "Asia/Hong_Kong",
            "Asia/Calcutta", "Europe/Paris", "Europe/London",
            "America/New_York", "America/Los_Angeles"
        };
        private final JLabel[] labels = new JLabel[zones.length];
        private final SimpleDateFormat[] formats = new SimpleDateFormat[zones.length];
        private JSpinner spinner;
        private SpinnerDateModel model;
        private SimpleDateFormat format;
        private JPanel panel;
        private JFrame frame = new JFrame();
    
        public void makeUI() {
            Calendar cal = Calendar.getInstance();
            Date date = cal.getTime();
            model = new SpinnerDateModel();
            model.setValue(date);
            spinner = new JSpinner(model);
            spinner.addChangeListener(new ChangeListener() {
    
                @Override
                public void stateChanged(ChangeEvent e) {
                    Date date = (Date) ((JSpinner) e.getSource()).getValue();
                    for (int i = 0; i < labels.length; i++) {
                        labels[i].setText(formats[i].format(date));
                    }
                }
            });
            format = ((JSpinner.DateEditor) spinner.getEditor()).getFormat();
            format.setTimeZone(TimeZone.getTimeZone(zones[0]));
            format.applyPattern("yyyy-MM-dd HH:mm:ss");
            panel = new JPanel(new GridLayout(zones.length, 2, 10, 10));
            for (int i = 0; i < zones.length; i++) {
                formats[i] = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
                formats[i].setTimeZone(TimeZone.getTimeZone(zones[i]));
                JLabel label = new JLabel(zones[i]);
                labels[i] = new JLabel(formats[i].format(date));
                panel.add(label);
                panel.add(labels[i]);
            }
            frame.setLayout(new BorderLayout(10, 10));
            frame.add(spinner, BorderLayout.NORTH);
            frame.add(panel, BorderLayout.CENTER);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new TimeZoneSpinners().makeUI();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have been trying couple of hours now to make my iphone app universal. The
I have a problem with the standard JSpinner.DateEditor (as probably does everyone else). When
I have a JSpinner with a Number Editor along the lines of: JSpinner spinner
JSpinner waitHr = new JSpinner(); waitHr.setEnabled(false); I have a spinner and I need to
I have a problem invoking the fireStateChanged() method for a JSpinner. I create a
i'm using a JSpinner like a table cell editor, i have one annoying problem:
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
have a nice day. I got problem when trying to create an image from
Have searched the database but need to specifically sum(of hours flown or days off)in
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:

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.