java - Daylight Savings Time (CST + CDT) - adding minutes issue -



java - Daylight Savings Time (CST + CDT) - adding minutes issue -

i updating scheduling application ability repeat appointment dates future.

the appointment future appointment time figured out finding amount of minutes between original appointment start time , end time. so, instance appointment 120 mins long. in below code, book period of time of time in appointments can made. so, booktime , appointments in getting copied. 1 iteration of appointment copying.

calendar begincalendar = calendar.getinstance(); begincalendar.settime(newbooktime.getstartdate()); begincalendar.add(calendar.minute, booktimediffminutes); newappointment.setstartdate(begincalendar.gettime()); calendar endcalendar = calendar.getinstance(); endcalendar.settime(newappointment.getstartdate()); endcalendar.add(calendar.minute, appointmentdiffminutes); newappointment.setstopdate(endcalendar.gettime());

the issue on daylight savings day cst turns cdt ... if start time of appointment 11pm on cst day , end time on cdt day 2am ... appointment ends hr later or before (depending if clocks turning or forward). because when add together x mins appointment ... there 1 less hr day, because skip hour.

so, when print dates can see on dst day time zone changes cst cdt:

the book time should 20:00-6:00

[stdout] book time start date:sat mar 07 20:00:00 cst 2015 [stdout] book time stop date:sun mar 08 07:00:00 cdt 2015

whereas on non-daylight savings alter day see:

[stdout] book time start date:sun mar 08 20:00:00 cdt 2015 [stdout] book time stop date:mon mar 09 06:00:00 cdt 2015

i want know how can compensate , ensure appointment , booktime right length on day timezone changes cst cdt. if had smart way of detecting alter add together or subtract 60 mins.

looking input.

it appears goal have appointment of same duration, regardless of whether appointment occurs during daylight or standard time, or happens straddle time change. given that, code works fine, output reflecting fact it's printing changed offsets: 10 hr appointment started @ 20:00:00 cst night before dst takes effect should end @ 07:00:00 cdt next day, since time zone have "sprung forward" hour.

java

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -