javafx - How to display day from selected date using javafx?
问题描述
I want to know the code how to get the day name of a selected date which select from the datepicker to a textfield using javafx and scenebuilder.
I use “Windows 10, MySQL 5.7.
this is what i tried. I want to get the day name of date in "txtDate" and set it to txtDay instead of adding it manually.
name of the datepicker field is txtDate) name of the text field is txtDay)
解决方案
你应该只使用DateTimeFormatter
例子
LocalDate day = LocalDate.now(); // or myDatePicker.getValue()
DateTimeFormatter format = DateTimeFormatter.ofPattern("EEEE", Locale.getDefault());
System.out.println(day.format(format));
myLabel.setText(day.format(format));
你会看到你想要什么“星期三”
推荐阅读
- html - 在表格单元格元素中创建垂直间隙
- android - 将布局转换为图像(布局截图)并存储在 Android 中
- python - 编码特殊字符以传递到 URL
- react-native - 如何从 Deco IDE 连接到我的 React Native 应用程序?
- graph - 如何在 Neo4J/Cypher 中对匹配的结果进行分组
- css - 如何使用 CSS sprites 制作图片链接
- python-3.x - Pandas groupby,执行操作,将结果添加到所述 groupby 数据框中的列
- javascript - 返回索引处第一项的内容
- swift - 尝试在闭包中使用泛型类型时出现意外的编译器错误
- c# - 无需手动读取即可访问 `runtimeconfig.json` 内容