Bug 97404 - [OLE][API] Support DateTime type in org.eclipse.swt.ole.win32.Variant class
Summary: [OLE][API] Support DateTime type in org.eclipse.swt.ole.win32.Variant class
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows All
: P3 enhancement with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, triaged
: 171131 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-31 05:15 EDT by Vitaly Logvinchuk CLA
Modified: 2017-07-12 05:26 EDT (History)
8 users (show)

See Also:


Attachments
VariantEx.java (27.12 KB, text/plain)
2005-06-01 03:01 EDT, Vitaly Logvinchuk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaly Logvinchuk CLA 2005-05-31 05:15:46 EDT
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.
Comment 1 Veronika Irvine CLA 2005-05-31 11:08:11 EDT
Would you like to contribute your implementation of Variant to the Eclipse 
Open Source project?
Comment 2 Vitaly Logvinchuk CLA 2005-06-01 03:01:07 EDT
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.
Comment 3 Iwan Birrer CLA 2005-09-30 08:54:01 EDT
Are there any plans to intgreate this patch in future releases?

Comment 4 Veronika Irvine CLA 2005-09-30 16:59:19 EDT
I will look at this on Monday and try to commit the changes for 3.2 M3.
Comment 5 Veronika Irvine CLA 2005-10-03 15:34:17 EDT
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)).
Comment 6 Iwan Birrer CLA 2005-10-05 04:30:01 EDT
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).
Comment 7 Jens Vagts CLA 2005-12-20 04:48:18 EST
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 :( ...
Comment 8 Basil CLA 2006-03-06 06:51:24 EST
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)).

Comment 9 Veronika Irvine CLA 2006-03-07 10:20:09 EST
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()
Comment 10 Kevin Haaland CLA 2006-03-07 13:25:30 EST
+1
Comment 11 Veronika Irvine CLA 2006-03-07 13:56:00 EST
Added support for VT_I8 and VT_R8 for 3.2.
Comment 12 Duong Nguyen CLA 2007-02-02 15:36:06 EST
*** Bug 171131 has been marked as a duplicate of this bug. ***
Comment 13 Felipe Heidrich CLA 2009-08-13 09:38:39 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 14 Niraj Modi CLA 2014-06-26 03:39:30 EDT
*** Bug 437740 has been marked as a duplicate of this bug. ***