- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在 JCalendar
中使用 JDateChooser (与 Swing )。我正在尝试获取“yyyy-MM-dd”的格式,但出于某种原因我也得到了时间并且它总是相同的(00:00:00 MDT)。任何人都知道如何摆脱时间?提前致谢。
try {
calendarDate = new JDateChooser();
} catch (Exception e) {
e.printStackTrace();
}
calendarDate.setDateFormatString("yyyy-MM-dd");
dateLabel = new JLabel("Date");
parent.frame2.getContentPane().add(dateLabel);//1
parent.frame2.getContentPane().add(calendarDate);
最佳答案
要让 JDateChooser
显示特定的日期格式,您需要使用其 setDateFormatString
API 设置该特定格式
示例:
JDateChooser myDateChooser = new JDateChooser();
myDateChooser.setDateFormatString("yyyy-MM-dd");
你已经在做 gthis 了吗?然后你必须发布你从组件中获取值(value)的地方。
在处理 JDateChooser 属性更改的地方,您可以执行类似以下操作以获取相同格式的日期:
示例:(假设 String dateString 是您想要日期字符串的位置)
myDateChooser.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("date")) {
dateString = new SimpleDateFormat("yyyy-MM-dd").format(myDateChooser.getDate());
}
}
});
关于java - 在 JCalendar 中使用 JDateChooser 不需要的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7639214/
我在一帧中使用JDateChooser和一些组合框。当我在 JDateChooser 中打开 popupcalendar 并在外部单击鼠标时,此弹出菜单将关闭。 问题:当我打开此日历然后单击任何组合框
我正在使用 jcalendar-1.2.2 jar 中的 JDateChooser。我已将 dateformatString 设置为“yyyyMMdd”。默认情况下,它显示今天的日期 2010 年 9
我正在使用下面的库JDateChooser,它是一个日期选择器 GUI,我们可以将其放入 Netbeans 托盘中。 http://plugins.netbeans.org/plugin/658/jd
我正在尝试将 focusListener 添加到 JDateChooser,以便当用户选择 dateOfBirth 时,当焦点丢失时,它会在文本字段上显示年龄。但它不起作用这是我尝试过的方法, 导入j
我正在将 JDateChooser 用于 Java 应用程序(这是我第一次使用它)。我想在 JDateChooser 为空时捕获错误,代码如下: if(dcs1.getDate().toString(
我在我的 Java 项目中使用 jDate Chooser我需要从 jDateChooser 检索日期并将其放入 mySQL 表中我使用的方法是 newBirthDate=(Date)inBirthD
这个问题已经有答案了: Is it possible to detect a date change on a JCalendar JDateChooser field? (2 个回答) 已关闭 5
我有一个表单,我想在其中访问数据库中的日期并在 jDateChooser 中显示特定记录。如何从数据库表中获取日期以及如何在 jDateChooser 中设置该日期?我的数据库中的数据类型是日期。
我正在使用 netbeans 和 MySQL Workbech 开发一个项目。 我有一个注册表单,我希望用户选择一个日期。如果他们不选择日期,我想使用今天的日期作为默认日期。 我正在使用 jcalen
我想在 JCalendar 上禁用多个日期范围.我正在关注 these steps ,但我需要知道如何添加多个日期评估器。请帮助我,谢谢。 更新:我不知道为什么我不能禁用 JCalendar 上的日期
我正在使用 JCalendar 的 1.4 JDateChooser 所以我问是否可以更改月份和星期几的显示名称而无需更改源代码,或者,因为没看过源码,能改也改不复杂。谢谢。 最佳答案 JCalend
我有一个表单,我想在该表单上访问数据库中的日期并在 jDateChooser 中显示特定记录。 我将日期作为字符串保存在数据库中。 如何从数据库表中获取日期以及如何在 jDateChooser 中设置
我需要对齐 Jdatechooser 文本字段中的文本。它总是将文本(所选日期)对齐到左侧,但我需要在右侧。 我已经尝试过,但它不起作用, StartJCal.setAlignmentX(RIGHT_
我通过搜索如何在 Java Swing 中使用 Item Combobox 发现了这个 JDateChooser。你知道如何安装吗? 这是链接JDateChooser 我找不到任何关于如何安装它的说明
我使用JDateChooser编辑表单中的日期。 简短版本:我需要区分 JDateChooser 上的用户日期编辑和编程属性更改。 解决方法:我发现了一个名为 dateSelected 的 prote
我在 netbeans 上使用 jDateChooser 插件。当应用程序启动时,它会抛出nullpointerException,但是当我选择日期时,它工作正常。唯一的问题是它在运行时抛出异常。以下
我正在尝试从 JDateChooser 获取值并将其用作文件名我创建了一个带有路径的文件,我可以在上面写入,但唯一的问题是我无法将其名称更改为变量(数据来自 JDateChooser) 这是部分代码:
我需要将当前日期设置为 jdatechooser 这段代码是不工作 Date date = new Date (); Jdatechooser.setDate(date); 最佳答案 您需要一个日期选
是否可以将焦点从 jFormattedTextField 更改为 JDateChooser? 我尝试过以下方法: jFormattedTextField.addActionListener(new A
我有一个机场项目。我有一个图形用户界面,我想在其中搜索某些航类。在这个图形用户界面中,我有一个 JDateChooser(因为我想在我的数据库中找到某个航类)。在数据库中,我有一个名为 date_de
我是一名优秀的程序员,十分优秀!