Community
Participate
Working Groups
I work with "Outlook" OLE objects. Several OLE classes have datetime fields. (e.g. class: "ContactItem", fields:"LastModificationTime", "Birthday"). OLE returns the DateTime fields as double values. I receive the values of these fields as object of Variant type. Then I use "getFloat()" method of Variant class for getting value(this method return value of "float" type). The received value of DateTime field is not exactly! I lose precision in seconds! I think the "double" type must be used for getting DateTime fields. P.S. I wrote my own implementation of Variant class using double type for getting (setting) DateTime field. After that I receive exactly value of DateTime field. I think the org.eclipse.swt.ole.win32.Variant class must be updated for working with double type.
Would you like to contribute your implementation of Variant to the Eclipse Open Source project?
Created attachment 22125 [details] VariantEx.java For my project I wrote my own implementation of Variant class (see attached VariantEx class). In this class I define additional implementation for getting/setting data of double type; also I write additionally parts to "getData" and "setData" methods for correct work with VT_DATE and VT_R8 types.
Are there any plans to intgreate this patch in future releases?
I will look at this on Monday and try to commit the changes for 3.2 M3.
Treating the date as a double has pitfalls as described in the following blog: http://blogs.msdn.com/ericlippert/archive/2003/09/16/53013.aspx In addition, this is a very confusing format for Java users because it is quite different from what is expected by other API. Microsoft provides conversion functions to and from strings. This may be a better way to go because then the OS is providing the logic of converting the value. In addition java.util.DateFormat can parse strings and provide a UTC Java Date result. In addition, there needs to be a constructor that will take a date value (possibly Variant(String date, int type) where type is VT_DATE to avoid confusion with the BSTR constructor Variant(String)).
It would still be nice to have a method getDouble(). Not primarely to get VT_DATE values but VT_R8 values (e.g from excel).
I'm also _realy_ interessted in VT_R8 support! Wy did you not commit the patch, it's still not in swt (3.2 M4) although you wanted to commit it for 3.2 M3 :( ...
Hi, I would like to know if there is any news concerning this bug, especially about handling the double values / VT_R8 values ... I understand that concerning the date, but for getting just a double value, it is very useful, I would even say indispensable ... cheers ... (In reply to comment #5) > Treating the date as a double has pitfalls as described in the following blog: > > http://blogs.msdn.com/ericlippert/archive/2003/09/16/53013.aspx > > In addition, this is a very confusing format for Java users because it is quite > different from what is expected by other API. > > Microsoft provides conversion functions to and from strings. This may be a > better way to go because then the OS is providing the logic of converting the > value. In addition java.util.DateFormat can parse strings and provide a UTC > Java Date result. > > In addition, there needs to be a constructor that will take a date value > (possibly Variant(String date, int type) where type is VT_DATE to avoid > confusion with the BSTR constructor Variant(String)).
KH, Can I have permission to add the following 4 API methods to Variant for 3.2: public Variant(double val) public Variant(long val) double Variant.getDouble() long Variant.getLong()
+1
Added support for VT_I8 and VT_R8 for 3.2.
*** Bug 171131 has been marked as a duplicate of this bug. ***
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
*** Bug 437740 has been marked as a duplicate of this bug. ***