我的GUI上显示了这个日期。我希望我的数据库存储此日期值。怎么做?图像是显示日期的图像。如何在文本字段和数据库中显示此日期? (sql server)
public class ClockPane extends JPanel {
private static final long serialVersionUID = 1L;
private JLabel clock;
public ClockPane() {
setBounds(235, 25, 580, 43);
setLayout(new BorderLayout());
setBackground(Color .white);
clock = new JLabel();
clock.setHorizontalAlignment(JLabel.CENTER);
clock.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD, 15f)); //15f = size of timer
tickTock();
add(clock);
Timer timer = new Timer(500, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tickTock();
}
});
timer.setRepeats(true);
timer.setCoalesce(true);
timer.setInitialDelay(0);
timer.start();
}
public void tickTock() {
clock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}