Java Date parse String like "2020-01-31 12:12" to date
import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] argv) { String sMt = "2020-01-31 12:12"; System.out.println(convertStringToDate(sMt)); }/*from w w w . j a v a 2 s .com*/ public static Date convertStringToDate(String sMt) { try { java.util.Date utilDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sMt); return utilDate; } catch (Exception e) { e.printStackTrace(); return null; } } }