Mega Code Archive

 
Categories / Java Tutorial / Development
 

Parsing custom formatted date string into Date object using SimpleDateFormat

import java.text.SimpleDateFormat; import java.util.Date; public class Main {   public static void main(String[] args) throws Exception {     SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");     Date date = sdf.parse("31/12/06");     System.out.println(date);   } } //Sun Dec 31 00:00:00 PST 2006