简体   繁体   English

如果JTable包含字符串,如何在JTable上使用RowFilter.dateFilter

[英]How to use RowFilter.dateFilter on JTable if it contains Strings

I want to use a RowFilter.dateFilter on a JTable, but my Table has only Strings formatted like this "yyyy-MM-dd". 我想在JTable上使用RowFilter.dateFilter,但是我的表只有这样的字符串,其格式为“ yyyy-MM-dd”。 If it's not possible to filter my JTable through a dateFilter, how can I solve this problem? 如果无法通过dateFilter过滤JTable,如何解决此问题?

thanks 谢谢

You should be storing Date objects in your TableModel, not a String representation of the date. 您应该在表模型中存储Date对象,而不是日期的String表示形式。 Then you can use a renderer to format the date however you want it displayed. 然后,您可以使用渲染器格式化日期,但要显示它。 See Table Format Renderers for an example renderer. 有关示例渲染 ,请参见表格式渲染器。

Now you can use the DateFilter the way it was designed to be used. 现在,您可以按照设计使用的方式使用DateFilter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM