Java SimpleDateFormat parse String like "31/10/2020 12:30:15" to Date

Description

Java SimpleDateFormat parse String like "31/10/2020 12:30:15" to Date


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        Date dt = sdf.parse("31/10/2020 12:30:15");
        System.out.println(dt);/* ww w.ja  va2s.  c  o  m*/
    }
}



PreviousNext

Related