Mega Code Archive

 
Categories / Java / Data Type
 

Convert date string from one format to another format using SimpleDateFormat

import java.text.SimpleDateFormat; import java.util.Date; public class Main {   public static void main(String[] args) throws Exception {     SimpleDateFormat sdfSource = new SimpleDateFormat("dd/MM/yy");     Date date = sdfSource.parse("12/11/09");     SimpleDateFormat sdfDestination = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");     System.out.println(sdfDestination.format(date));   } }