I have two Jdatechooser(named as firstdate and lastdate) and Jspinner(named as starttime and endtime) in a gui.
The scenario is,
1.if i open gui i will get the current time and set it in endtime and currenttime-1 in starttime(the code is below),
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, -1);
Date oneHourBack = cal.getTime();
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(oneHourBack);
Date date = new SimpleDateFormat("HH:mm:ss").parse(timeStamp);
starttime.setValue(date);
2.For both the Jdatechooser i set the current date.
3.If current time is 00:44:36 (HH:mm:ss), in starttime(Jspinner) i have to set 23:44:36, with this i have to set the firstdate(Jdatechooser) value to previous day date instead of current date.
for this am trying the following way,
Calendar currentTime = Calendar.getInstance();
Date curHr = currentTime.getTime();
String curtime = new SimpleDateFormat("HH").format(curHr);
int timeCheck = Integer.parseInt(curtime);
if(timeCheck > 00 && timeCheck < 01){
//code to set previous day's
date
}
is this the way to do it? or is there any better way available? Please help