0

I have this date shown on my GUI. I want my database to store this date value. How to do it? The image is that of the date shown. How to display this date to a text field and to my database? (sql server)

Link of image

    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()));
    }
TuffBee
  • 33
  • 1
  • 8

0 Answers0