Hey guys
I have a method that is calculating a time based two JComboBox selections.
I am returning the time as a Date object but it prints the date and time, when I say
'cal.getTime()'. The date is always the same, the format is Thu Jan 01 (time i calculated) GMT 1970. I was wondering if there is an easy way of just getting the time. I know I can convert it into a String then get the substring of the time, but if I do that i will have to convert it to date again when I am going to use it. Any help would be appreciated I supplied the method below.

public Date curBookingEndTime(){
               //String date= dateTextF.getText();

                    Calendar cal= Calendar.getInstance();
                    DateFormat format= new SimpleDateFormat("hh:mm");
                    java.util.Date dateUtil2 = new java.util.Date();
                    Date calcuDate=null;

                    try {
                        dateUtil2 = format.parse(selected);
                        System.out.println("selected "+ selected);
                    }
                    catch (ParseException ex) {
                        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    cal.setTime(dateUtil2);
                    int x= Integer.parseInt(selectGuest);
                    System.out.println("XXXX "+ x);
                    for(int i=1; i<=x;i++){
                        cal.add(cal.MINUTE, 30);
                        if(x==i){
                            System.out.println("cal.getTime "+cal.getTime());
                        calcuDate= cal.getTime();

                        }

        }
                    System.out.println("end time= "+ calcuDate);
                  return calcuDate;
                    }
This article has been dead for over six months. Start a new discussion instead.