internal static long JavaDateToClrTicks(java.util.Date d) { long millis = JavaMillisToClrMillis(d.getTime()); if (DEFAULT_TIME_ZONE.inDaylightTime(d)) { millis += DEFAULT_TIME_ZONE.getDSTSavings(); } return millis * TimeSpan.TicksPerMillisecond; }
internal static long JavaTimeToClrTicks(java.sql.Time t) { return (t.getTime() + DEFAULT_TIME_ZONE.getRawOffset()) * TimeSpan.TicksPerMillisecond; }
/// <summary> /// Converts a Java Date value to a DateTime value /// </summary> /// <param name="javaDate">The Java date</param> /// <returns></returns> private static DateTime FromJavaDate(java.util.Date javaDate) { if (_configTimeZone == null) { // Read time zone from market-hours-config _configTimeZone = MarketHoursDatabase.FromDataFolder().GetDataTimeZone("fxcm", "*", SecurityType.Forex); } // Convert javaDate to UTC Instant (Epoch) var instant = Instant.FromSecondsSinceUnixEpoch(javaDate.getTime() / 1000); // Convert to configured TZ then to a .Net DateTime return instant.InZone(_configTimeZone).ToDateTimeUnspecified(); }