/// <summary>
            /// Converts the absolute duration represented by
            /// the given <see cref="System.TimeSpan"/>
            /// value to an <see cref="System.Int64"/> value
            /// representing the number of milliseconds since
            /// <c>January 1, 1970 00:00:00 GMT</c>.
            /// </summary>
            /// <param name="timeSpanValue">
            /// For which to retrieve the <c>Int64</c> value.
            /// </param>
            /// <returns>
            /// The corresponding value.
            /// </returns>
            public static long ToTimestampInMillis(TimeSpan timeSpanValue)
            {
                timeSpanValue = timeSpanValue.Duration();

                JavaGregorianCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                cal.clear();
                cal.add(JavaCalendar.DAY_OF_YEAR, timeSpanValue.Days);
                cal.add(JavaCalendar.HOUR_OF_DAY, timeSpanValue.Hours);
                cal.add(JavaCalendar.MINUTE, timeSpanValue.Minutes);
                cal.add(JavaCalendar.SECOND, timeSpanValue.Seconds);
                cal.add(JavaCalendar.MILLISECOND, timeSpanValue.Milliseconds);

                return cal.getTimeInMillis();
            }
            /// <summary>
            /// Retrieves the absolute duration, in whole number of days,
            /// of the given <see cref="System.TimeSpan"/> value as
            /// the number of milliseconds since
            /// <c>January 1, 1970, 00:00:00 GMT</c>.
            /// </summary>
            /// <param name="timeSpanValue">
            /// To convert to an <c>Int64</c> date in milliseconds value.
            /// </param>
            /// <returns>
            /// The corresponding <c>Int64</c> value.
            /// </returns>
            public static long ToDateInMillis(TimeSpan timeSpanValue)
            {
                timeSpanValue = timeSpanValue.Duration();

                JavaGregorianCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                cal.clear();
                cal.add(JavaCalendar.DAY_OF_YEAR, timeSpanValue.Days);

                return cal.getTimeInMillis();
            }
            /// <summary>
            /// Retrieves the number of milliseconds since 
            /// <c>January 1, 1970, 00:00:00 GMT</c> represented
            /// by the <c>Hours</c>, <c>Minutes</c> and <c>Seconds</c>
            /// portions of the given <see cref="TimeSpan"/>,
            /// interpreted as an absolute duration.
            /// </summary>
            /// <param name="value">
            /// For which to retrieve the <c>Int64</c> value.
            /// </param>
            /// <returns>
            /// The corresponding value.
            /// </returns>
            public static long ToTimeInMillis(TimeSpan value)
            {
                value = value.Duration();

                JavaCalendar cal = HsqlConvert.GetJavaGregorianCalendar();

                cal.clear();
                cal.set(JavaCalendar.HOUR_OF_DAY, value.Hours);
                cal.set(JavaCalendar.MINUTE, value.Minutes);
                cal.set(JavaCalendar.SECOND, value.Seconds);

                return cal.getTimeInMillis();
            }
Ejemplo n.º 4
0
 public TimeSpan Duration()
 {
     return(new TimeSpan(m_base.Duration(), System.Math.Abs(m_microseconds), System.Math.Abs(m_nanoseconds)));
 }