From 3b5728de6f2d8d2852fbb86fa8cac21e6dccc19b Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 4 May 2015 22:11:28 +0200 Subject: Build a file browser looking like Finder --- .../tables/LocalDateTimeTableCellFactory.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java (limited to 'src/de/fhswf/fbin/java2fx/tables/LocalDateTimeTableCellFactory.java') 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 implements + Callback, TableCell> +{ + @Override + public TableCell call(TableColumn param) + { + return new TableCell() + { + @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); + } + } + }; + } +} -- cgit v1.2.3-70-g09d2