mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Cache time formatter
This commit is contained in:
@@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user