1.
import ;
import ;
import ;
public class T {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int hour = 12;
try{
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat formatTime = new SimpleDateFormat("MM/dd/yyyy hh:mm aa",);
SimpleDateFormat formatTimea = new SimpleDateFormat("MM/dd/yyyy HH:mm");
String pickUpTime=(new Date());
String pickUpDateTime = pickUpTime+" "+hour+":00";
Date date = (pickUpDateTime);
("a: "+(date));
}
catch(Exception e){
();
}
}
2.
private static final SimpleDateFormat formatTimeAA = new SimpleDateFormat("MM/dd/yyyy hh:mm aa",);
public Date getDate(String time,int hour) throws ParseException {
String AA = " AM";
if(hour>11){
AA = " PM";
if(hour>12){
hour = hour -12;
}
}
String pickUpDateTime = time+" "+hour+":00";
pickUpDateTime = pickUpDateTime + AA;
Date date = (pickUpDateTime);
return date;
}