/*
@Author: M. Lakshmikar Reddy
@Designation: Software Engineer
@Date:22/07/2011
*/
import java.text.SimpleDateFormat;
import java.util.Date;
// used to convert one date format into another
public class ConvertertoOtherDateFormat {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdfSource = new SimpleDateFormat("M/d/yy h:mm:ss a");
Date date = sdfSource.parse("1/1/09 2:25:31 PM");
SimpleDateFormat sdfDestination = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
System.out.println(sdfDestination.format(date));
}
}
/*output:
*01/01/2009 02:25:31 PM
*/
No comments:
Post a Comment