5
I am developing a system for hotel and reservation I need the date of entry is greater than or equal to that of the reservation, and the exit is greater than that of the entrance.
I made these conditions, but when I test the reservation date and entry date equal I can not make the registration.
I don’t know what could be wrong with my method code.
Could someone help me??
private boolean verificaData(Calendar dcDataReserva, JDateChooser dcDataEntrada, JDateChooser dcDataSaida){
Calendar Data_Reserva = Calendar.getInstance();
Calendar Data_Entrada = dcDataEntrada.getCalendar();
Calendar Data_Saida = dcDataSaida.getCalendar();
boolean data;
if(Data_Entrada.before(Data_Reserva) && (Data_Saida.before(Data_Entrada))){
data= false;
}else
if((Data_Entrada.after(Data_Reserva)) && (Data_Saida.after(Data_Entrada))){
data = true;
}else
if(Data_Reserva.equals(Data_Entrada)){
data = true;
}else{
data = false;
}
return data;
}
in the third comparison, the date of departure is earlier than the date of entry. Obg Diego F, but you said that in the third comparison the departure date is earlier... but I put later... I tested with IDEONE’s if, and I still can’t register with the same reservation and entry dates.
– Lizy
@Lizy yes, as I said in the answer, there I did 3 demonstrations so that you could observe that it is validating correctly, according to the conditions you mentioned in the question. Note that you only enter if in the first condition, which is where the check-in date is later than the booking date and earlier than the check-out date;
– user28595
@Lizy this solution did not serve you? Let me know if you are having problem for me to review.
– user28595
I tested the suggestion that you gave me, but I still can not register when the date of reservation and entry date are equal, ie, Reserve date = 23/04/2016, Date Entry 23/04/2016 and exit date = 24/04/2016 as example.
– Lizy
@Lizy fix it in ideone, see that it works perfectly.
– user28595
@Lizy still not working?
– user28595
Hello @Diego F, not yet! The other functions do work but the option to put the same date for a reservation and input date does not work, displays error message! I need to exist this option of the booking date and entry be on the same day, month, year! Obg!
– Lizy
@Is Lizy an application made in swing? Could you provide the code of this screen? Maybe the problem is elsewhere in the code.
– user28595
Yes it is an application made in java swing!!! I will send you the code!!!
– Lizy
@Lizy seems that you had added in my reply and the staff rejected it. Paste the code here Pastebin.com and return me with the link.
– user28595
Hello @Diego F I appreciate the collaboration but I already solved the problem, and I’m sorry for the mistake, I’m new here... I found a pc complicated edit to paste, but now td well! Obg!
– Lizy