Пример #1
0
        /// <summary>
        /// Convert a DateTime instance to a Java Date instance.
        /// </summary>
        /// <param name="d">DateTime instance</param>
        /// <returns>Java Date instance</returns>
        public static java.util.Date ToJavaDate(this DateTime d)
        {
            TimeSpan ts        = d - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
            long     timestamp = (long)ts.TotalMilliseconds;

            java.util.TimeZone tz     = java.util.TimeZone.getDefault();
            java.util.Date     result = new java.util.Date(timestamp - tz.getRawOffset());

            if (tz.inDaylightTime(result) == true)
            {
                int savings = tz.getDSTSavings();
                result = new java.util.Date(result.getTime() - savings);
            }
            return(result);
        }
Пример #2
0
		static DbConvert()
		{
			DEFAULT_TIME_ZONE = java.util.SimpleTimeZone.getDefault();			
			TIMEZONE_RAW_OFFSET = (long)DEFAULT_TIME_ZONE.getRawOffset();						
		}
Пример #3
0
 static DbConvert()
 {
     DEFAULT_TIME_ZONE   = java.util.SimpleTimeZone.getDefault();
     TIMEZONE_RAW_OFFSET = (long)DEFAULT_TIME_ZONE.getRawOffset();
 }
Пример #4
0
 internal static java.sql.Time ClrTicksToJavaTime(long ticks)
 {
     return(new Time((ticks / TimeSpan.TicksPerMillisecond)
                     - DEFAULT_TIME_ZONE.getRawOffset()));
 }