I'd like my dateField to accept two date formats. The solution I currently has only accepts the final element from the String array. Is it possible to accept both date formats?
import java.text.SimpleDateFormat;
import javax.swing.*;
public class TimeConverterView extends JPanel {
private JFormattedTextField dateField;
private final String[] DATE_FORMATS = {"yyy.DDD.HH.mm.ss", "yyyy/MM/dd HH:mm:ss"};
public TimeConverterView() {
for (String s : DATE_FORMATS){
dateField = new JFormattedTextField(new SimpleDateFormat(s));
}
}
}