Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Support a date with the custom format

import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.JFormattedTextField; public class Main {   public static void main(String[] argv) throws Exception {     JFormattedTextField tft3 = new JFormattedTextField(new SimpleDateFormat("yyyy-M-d"));     tft3.setValue(new Date());        Date date = (Date) tft3.getValue();   } }