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