简体   繁体   中英

SWT DateTime strange behaviour

I'm using a SWT DateTime widget and got a very strange behaviour. If I choose any date out of the month "February", "April" or "June" the displayed date is the date I choosed but with month "January". In my datebase the right date is saved, only the displayed date in my editor is wrong. Other months are working fine. The following example is how I set my "Date"-Object within my "DateTime"-Object.

Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
dateTime.setYear(calendar.get(Calendar.YEAR));
dateTime.setMonth(calendar.get(Calendar.MONTH));
dateTime.setDay(calendar.get(Calendar.DAY_OF_MONTH));

I can't explain this behaviour. For me it seems like an error within the DateTime widget. Any tips how to avoid this?

Solved the problem now. The solution is described in this bugzilla-thread: bugs.eclipse.org/bugs/show_bug.cgi?id=190254. The trick is to set the day_of_month before setting the month in my DateTime-Widget

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM