これはコードです。コードの出力は "Thu Jun 06 08:00:00 PKT 2013" ですが、2013-06-08 00:00:00 の形式が必要です。
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.*;
import javax.script.*;
public class time {
public static void main (String[] args)throws ParseException{
String date1 = "2013/06/06";
String time1 = "08:00 AM";
String time2 = "18:00 PM";
SimpleDateFormat sdf = new SimpleDateFormat("yyy/MM/dd hh:mm ");
try{
Date dateObj1 = sdf.parse(date1 + " " + time1);
Date dateObj3 = sdf.parse(date1 + " " + time2);
System.out.println("Date Start: "+dateObj1);
System.out.println("Date End: "+dateObj3);
int c=0;
long dif = dateObj1.getTime();
while (dif < dateObj3.getTime()) {
System.out.println(c++);
Date slot = new Date(dif);
System.out.println("Hour Slot --->" + slot);
dif+=3600000;
}
System.out.println("c is :"+c);
}
catch(ParseException e){
;
}
}
}