Hey everyone,
I have an assignment that I am totally lost on...
I am in 2nd year of Systems Development...
Please assist me on what I am missing or doing wrong
I have to have a GUI that will select a date and time...
Basically, I need Monday - Saturday with working hours and Sunday needs different working hours.
My code so far works for everyday, but I am struggling with Sunday.
I have to use JXDatePicker (unless there is something else I can use...)
If I select the day and it's out of operating hours, it needs to throw an error.
If I select a valid day and time, it needs to go to my list box.
My time is selected from a combobox and my date is selected from JXDatePicker.
MY CODE THAT WORKS FOR EVERYDAY:
try
{
SimpleDateFormat parser = new SimpleDateFormat("HH:mm");
Date opening = parser.parse("09:00");
Date closing = parser.parse("22:00");
Date userDate = parser.parse((String) txtTime.getSelectedItem());
if (userDate.after(opening) && userDate.before(closing))
{
JOptionPane.showMessageDialog(null,"Success");
dlmList.addElement(txtTime.getSelectedItem().toStr ing());
}
else
{
JOptionPane.showMessageDialog(null, "Invalid Time");
}
} catch (ParseException ex) {
Logger.getLogger(Customer.class.getName()).log(Lev el.SEVERE, null, ex);
}
-NOT SURE IF I NEED TO ADD THE BELOW CODE FOR THE DATE...
BUT WHEN I CHANGE THE DATE FORMAT AS BELOW, IT WRITES; DAY DATE YEAR TIME AND TIMEZONE INSTEAD OF JUST DAY AND DATE TO MY LIST...
I do think it is the settings of JXDatepicker, and it doesn't allow me to remove the timezone.
try
{
Date Date = new Date();
SimpleDateFormat SimpleDateformat = new SimpleDateFormat("EEEE"); // the day of the week spelled out completely
Object dayOfWeek = null;
if(dayOfWeek == "Sunday")
{
String opening = "08:00";
String closing = "21:00";
}
else
{
String opening = "09:00";
String closing = "22:00";
}
}