//
// The following example code demonstrates how to
// create a Date object set to a specific date and time using the Calendar class.
//
public class GetSpecificDateObject {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.SECOND, 8);
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.HOUR, 8);
calendar.set(Calendar.AM_PM, Calendar.AM);
calendar.set(Calendar.MONTH, Calendar.AUGUST);
calendar.set(Calendar.DAY_OF_MONTH, 8);
calendar.set(Calendar.YEAR, 2008);
Date date = calendar.getTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss a");
System.out.println(dateFormat.format(date));
}
}
Subscribe To Our Newsletter
Join our low volume mailing list to receive the latest news and updates from our team.