summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-05-04 22:11:28 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-05-04 22:11:28 +0200
commit3b5728de6f2d8d2852fbb86fa8cac21e6dccc19b (patch)
tree54965319a9aafeb294dac8e36e4ce1371ec76ef3 /src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java
parentaf7b9bd6a962b9a290fc5d78c08c83653961811f (diff)
downloadJava2-3b5728de6f2d8d2852fbb86fa8cac21e6dccc19b.tar.gz
Java2-3b5728de6f2d8d2852fbb86fa8cac21e6dccc19b.zip
Build a file browser looking like Finder
Diffstat (limited to 'src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java')
-rw-r--r--src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java b/src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java
new file mode 100644
index 0000000..0c5c41d
--- /dev/null
+++ b/src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java
@@ -0,0 +1,37 @@
+package de.fhswf.fbin.java2fx.tables;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import javafx.scene.control.TableCell;
+import javafx.scene.control.TableColumn;
+import javafx.util.Callback;
+
+public class LocalDateTimeTableCellFactory<S> implements
+ Callback<TableColumn<S, LocalDateTime>, TableCell<S, LocalDateTime>>
+{
+ @Override
+ public TableCell<S, LocalDateTime> call(TableColumn<S, LocalDateTime> param)
+ {
+ return new TableCell<S, LocalDateTime>()
+ {
+ @Override
+ protected void updateItem(LocalDateTime item, boolean empty)
+ {
+ super.updateItem(item, empty);
+
+ if (!empty)
+ {
+ ZonedDateTime zdt = ZonedDateTime.of(item, ZoneId.systemDefault());
+ setText(zdt.format(DateTimeFormatter.RFC_1123_DATE_TIME));
+ }
+ else
+ {
+ setText(null);
+ }
+ }
+ };
+ }
+}