public class TimeTwo { public static void main(String[] args) throws ParseException{ String s = "2018-08-12 12:02:23"; SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd MM:mm:ss"); try{ Date h = g.parse(s); // System.out.println(h); }catch (ParseException e){ e.printStackTrace(); } //格式String型转成Date型 DateFormat format3 = DateFormat.getDateInstance(DateFormat.LONG,Locale.SIMPLIFIED_CHINESE); try{ System.out.println("日期:"+format3.format(new Date())); }catch (Exception e){ e.printStackTrace(); } } }