Java将字符串转换为日期


Java将字符串转换为日期

import java.text.SimpleDateFormat;

import java.util.Date;



public class DateUtils {

   public static void main(String[] args) {

      SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

      try {

         Date today = sdf.parse("27/04/2018");

         System.out.println("Date is : " + today.toString());

     } catch(Exception e){System.out.println(e);}

   }

}