Things I've tried
public class Event {
private SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddTHHmmssZ");
private Date date;
private String summary;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public void setDate(String stringDate) throws ParseException {
this.date = formatter.parse(stringDate);
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
}
// main
String x = "20200926T221447Z"
Event event = new Event();
event.setDate(x);
Exception I get
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'T'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:826)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:634)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:605)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:580)
at stuff.calendar.Event.<init>(Event.java:9)
at stuff.calendar.App.main(App.java:34)
Question : Is my SimpleDateFormat incorrect? I've tried changing this around but none work. Is there another java API I should use to parse this particular time format?