简体   繁体   English

SWT DateTime奇怪的行为

[英]SWT DateTime strange behaviour

I'm using a SWT DateTime widget and got a very strange behaviour. 我正在使用SWT DateTime小部件,并且有一个非常奇怪的行为。 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". 如果我从“ 2月”,“ 4月”或“ 6月”月份中选择任何日期,则显示的日期是我选择的日期,但月份为“ 1月”。 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. 以下示例是我如何在“ DateTime”对象中设置“ Date”对象的方法。

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. 对我来说,DateTime小部件内似乎是一个错误。 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. 该解决方案在以下bugzilla线程中进行了描述: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 诀窍是在DateTime-Widget中设置月份之前先设置day_of_month

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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