0

I'm new to programming. How can I remove the zero next to the date (2022-04-21 00:00:00.000000)?

here is my code:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.format(jDateChooser1.getDate());
((JTextField)jDateChooser1.getDateEditor().getUiComponent()).setText(date);
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
model.addRow(new Object[]{date});
pst.setString(7, date);
James Z
  • 12,209
  • 10
  • 24
  • 44
  • You mean `get rid of the time component` within the date string? Well, that's exactly what your code does: `SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); jDateChooser1.setDateFormatString("yyyy-MM-dd"); String date = sdf.format(jDateChooser1.getDate()); System.out.println(date);`. – DevilsHnd - 退職した Apr 21 '22 at 12:52
  • hello, good evening. I already try that but it's still an error. @DevilsHnd – Ruth Nastor Apr 21 '22 at 13:27
  • What error? You should edit your question and provide the exact error message. – June7 Apr 21 '22 at 16:03

0 Answers0