Example #1
0
 //
 // Summary:
 //     Deserializes a 64-bit binary value and recreates an original serialized System.DateTime
 //     object.
 //
 // Parameters:
 //   dateData:
 //     A 64-bit signed integer that encodes the System.DateTime.Kind property in
 //     a 2-bit field and the System.DateTime.Ticks property in a 62-bit field.
 //
 // Returns:
 //     An object that is equivalent to the System.DateTime object that was serialized
 //     by the System.DateTime.ToBinary() method.
 //
 // Exceptions:
 //   System.ArgumentException:
 //     dateData is less than System.DateTime.MinValue or greater than System.DateTime.MaxValue.
 //public static DateTime FromBinary(long dateData);
 //
 // Summary:
 //     Converts the specified Windows file time to an equivalent local time.
 //
 // Parameters:
 //   fileTime:
 //     A Windows file time expressed in ticks.
 //
 // Returns:
 //     An object that represents the local time equivalent of the date and time
 //     represented by the fileTime parameter.
 //
 // Exceptions:
 //   System.ArgumentOutOfRangeException:
 //     fileTime is less than 0 or represents a time greater than System.DateTime.MaxValue.
 //public static DateTime FromFileTime(long fileTime);
 //
 // Summary:
 //     Converts the specified Windows file time to an equivalent UTC time.
 //
 // Parameters:
 //   fileTime:
 //     A Windows file time expressed in ticks.
 //
 // Returns:
 //     An object that represents the UTC time equivalent of the date and time represented
 //     by the fileTime parameter.
 //
 // Exceptions:
 //   System.ArgumentOutOfRangeException:
 //     fileTime is less than 0 or represents a time greater than System.DateTime.MaxValue.
 //public static DateTime FromFileTimeUtc(long fileTime);
 //
 // Summary:
 //     Returns a System.DateTime equivalent to the specified OLE Automation Date.
 //
 // Parameters:
 //   d:
 //     An OLE Automation Date value.
 //
 // Returns:
 //     An object that represents the same date and time as d.
 //
 // Exceptions:
 //   System.ArgumentException:
 //     The date is not a valid OLE Automation Date value.
 //public static DateTime FromOADate(double d);
 //
 // Summary:
 //     Converts the value of this instance to all the string representations supported
 //     by the standard date and time format specifiers.
 //
 // Returns:
 //     A string array where each element is the representation of the value of this
 //     instance formatted with one of the standard date and time format specifiers.
 //public string[] GetDateTimeFormats();
 //
 // Summary:
 //     Converts the value of this instance to all the string representations supported
 //     by the specified standard date and time format specifier.
 //
 // Parameters:
 //   format:
 //     A standard date and time format string (see Remarks).
 //
 // Returns:
 //     A string array where each element is the representation of the value of this
 //     instance formatted with the format standard date and time format specifier.
 //
 // Exceptions:
 //   System.FormatException:
 //     format is not a valid standard date and time format specifier character.
 //public string[] GetDateTimeFormats(char format);
 //
 // Summary:
 //     Converts the value of this instance to all the string representations supported
 //     by the standard date and time format specifiers and the specified culture-specific
 //     formatting information.
 //
 // Parameters:
 //   provider:
 //     An object that supplies culture-specific formatting information about this
 //     instance.
 //
 // Returns:
 //     A string array where each element is the representation of the value of this
 //     instance formatted with one of the standard date and time format specifiers.
 //public string[] GetDateTimeFormats(IFormatProvider provider);
 //
 // Summary:
 //     Converts the value of this instance to all the string representations supported
 //     by the specified standard date and time format specifier and culture-specific
 //     formatting information.
 //
 // Parameters:
 //   format:
 //     A date and time format string (see Remarks).
 //
 //   provider:
 //     An object that supplies culture-specific formatting information about this
 //     instance.
 //
 // Returns:
 //     A string array where each element is the representation of the value of this
 //     instance formatted with one of the standard date and time format specifiers.
 //
 // Exceptions:
 //   System.FormatException:
 //     format is not a valid standard date and time format specifier character.
 //public string[] GetDateTimeFormats(char format, IFormatProvider provider);
 //
 // Summary:
 //     Returns the hash code for this instance.
 //
 // Returns:
 //     A 32-bit signed integer hash code.
 //public override int GetHashCode();
 //
 // Summary:
 //     Returns the System.TypeCode for value type System.DateTime.
 //
 // Returns:
 //     The enumerated constant, System.TypeCode.DateTime.
 //public TypeCode GetTypeCode();
 //
 // Summary:
 //     Indicates whether this instance of System.DateTime is within the daylight
 //     saving time range for the current time zone.
 //
 // Returns:
 //     true if System.DateTime.Kind is System.DateTimeKind.Local or System.DateTimeKind.Unspecified
 //     and the value of this instance of System.DateTime is within the daylight
 //     saving time range for the current time zone. false if System.DateTime.Kind
 //     is System.DateTimeKind.Utc.
 //public bool IsDaylightSavingTime()
 //{
     //var calender = GetCalender();
     //return calender
 //}
 //
 // Summary:
 //     Returns an indication whether the specified year is a leap year.
 //
 // Parameters:
 //   year:
 //     A 4-digit year.
 //
 // Returns:
 //     true if year is a leap year; otherwise, false.
 //
 // Exceptions:
 //   System.ArgumentOutOfRangeException:
 //     year is less than 1 or greater than 9999.
 public static bool IsLeapYear(int year)
 {
     var calender = new Java.Util.GregorianCalendar();
     return calender.IsLeapYear(year);
 }
Example #2
0
        private Java.Util.Calendar GetCalendar()
        {
            var millis = (ticks / TimeSpan.TicksPerMillisecond) - EraDifferenceInMs;

            var calender = new Java.Util.GregorianCalendar();
            if (Kind == DateTimeKind.Utc || Kind == DateTimeKind.Unspecified)
            {
                calender.SetTimeZone(TimeZone.GetTimeZone("UTC"));
            }
            calender.SetTimeInMillis(millis);

            return calender;
        }