Skip to content

Commit

Permalink
Add method for converting windows time from SafeArray to Java Date
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykachalov committed Dec 5, 2018
1 parent 8c5ebe7 commit bf1e9eb
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion jacob/src/com/jacob/com/SafeArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package com.jacob.com;

import java.util.Date;

/**
* This creates an array wrapper around Variant objects(?). This supports 1, 2
* and n-dimensional arrays. It exists in this form because n-dimensional arrays
Expand Down Expand Up @@ -1063,14 +1065,36 @@ public native void setStrings(int sa_idx, int nelems, String ja[],
public native void setVariant(int indices[], Variant v);

/**
* get date from an single dimensional array
* get windows time from an single dimensional array
*
* @param sa_idx
* array index
* @return date stored in array
*/
public native double getDate(int sa_idx);

/**
* returns the Java Date contained in this array
*
* @param sa_idx1
* array index
* @return Java date stored in array
* @throws IllegalStateException
* if array is not of the requested type
*/
public Date getJavaDate(int sa_idx1) {
Date returnDate = null;
if (this.getvt() == Variant.VariantDate) {
double windowsDate = this.getDate(sa_idx1);
if (windowsDate != 0.0D) {
returnDate = DateUtilities.convertWindowsTimeToDate(windowsDate);
}
return returnDate;
} else {
throw new IllegalStateException("getJavaDate() only legal on SafeArray of type VariantDate, not " + this.getvt());
}
}

/**
* variant access
*
Expand Down

0 comments on commit bf1e9eb

Please sign in to comment.