From e4e58bfe2418337448b5e5035ecd8e542534a1a5 Mon Sep 17 00:00:00 2001 From: ollo Date: Thu, 27 Dec 2018 18:19:52 +0100 Subject: [PATCH] Added leading zero for all values: day,hour, minute, second --- simulation/src/de/c3ma/ollo/mockup/ui/WS2812Layout.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/simulation/src/de/c3ma/ollo/mockup/ui/WS2812Layout.java b/simulation/src/de/c3ma/ollo/mockup/ui/WS2812Layout.java index d6c01fc..ba32513 100644 --- a/simulation/src/de/c3ma/ollo/mockup/ui/WS2812Layout.java +++ b/simulation/src/de/c3ma/ollo/mockup/ui/WS2812Layout.java @@ -183,7 +183,9 @@ public class WS2812Layout extends JFrame { JButton but = (JButton) ae.getSource(); if (but.equals(btnSetCurrentTime)) { GregorianCalendar gc = new GregorianCalendar(); - dateTime.setText(""+gc.get(Calendar.YEAR) + "-" + gc.get(Calendar.MONTH) + "-" + gc.get(Calendar.DAY_OF_MONTH) + " " + gc.get(Calendar.HOUR_OF_DAY) + ":" + gc.get(Calendar.MINUTE) + ":" + gc.get(Calendar.SECOND)); + dateTime.setText(String.format("%d-%02d-%02d %02d:%02d:%02d", + gc.get(Calendar.YEAR), gc.get(Calendar.MONTH), gc.get(Calendar.DAY_OF_MONTH), + gc.get(Calendar.HOUR_OF_DAY), gc.get(Calendar.MINUTE), gc.get(Calendar.SECOND))); } } });