本文介绍了在swings中设置jspinner的时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用java swing应用程序。在该应用程序中,我必须从用户那里获取时间输入。
我需要制作一个JSpinner,只有hh:mm am / pm格式。我在属性中搜索但无法获得此格式。
I am working in a java swing application. In that application i have to take time input from user.I need to make a JSpinner for the time, only in the hh:mm am/pm format. i searched in properties but could not get this format.
请建议我以某种方式显示hh:mm am / pm格式的时间。我感谢您提出的宝贵建议。
Please suggest me some way to display time in hh:mm am/pm format. I thank to all your valuable suggestions.
推荐答案
您可以像这样设置编辑器和日期模型:
You can set an editor and a date model like this:
SpinnerDateModel model = new SpinnerDateModel();
model.setCalendarField(Calendar.MINUTE);
spinner= new JSpinner();
spinner.setModel(model);
spinner.setEditor(new JSpinner.DateEditor(spinner, "h:mm a"));
这篇关于在swings中设置jspinner的时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!