How to format date in UTC format for yyyy-mm-dd [duplicate]

0

I'm working with the XML of an NF-e where the date fields are in UTC format (YYYY-MM-DDThh: mm: ssTZD) and need to insert them into the database in the format yyyy-mm-dd. p>

I'm using SimpleDateFormat to try to do the conversion, but I get a ParseException with the message "Unparseable date". My code looks like this:

public Date getDataEvento() {
    DateFormat dt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    try {
        return dt.parse(this.dataEvento);
    } catch (ParseException e) {
        e.printStackTrace();
        return new Date();
    }
}
    
asked by anonymous 20.11.2017 / 14:29

0 answers