Cache time formatter

This commit is contained in:
drdev
2013-10-03 00:28:55 +00:00
parent ac48d3634b
commit 56654ffcb1

View File

@@ -15,6 +15,7 @@ import javax.swing.Timer;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FDigitalClock extends JLabel { public class FDigitalClock extends JLabel {
private final Calendar now = Calendar.getInstance(); private final Calendar now = Calendar.getInstance();
private final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);
public FDigitalClock() { public FDigitalClock() {
Timer timer = new Timer(60000, new ActionListener() { Timer timer = new Timer(60000, new ActionListener() {
@@ -30,6 +31,6 @@ public class FDigitalClock extends JLabel {
} }
private void updateDisplay() { private void updateDisplay() {
setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(now.getTime())); setText(timeFormatter.format(now.getTime()));
} }
} }