import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class DateObjectFromCalendar { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // Create Date object using Calendar object. Date date = cal.getTime(); SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); System.out.println("The date is:" + fmt.format(date)); } }
The output is:
The date is:23/07/2012 05:23:52
No comments:
Post a Comment