I could not convert system date and time into Calendar object

I tried this way to convert system date and time but it shows nothing
  Calendar startCalendar = CustomDateTime.DateTimeToCalendar(startDate);

startTimeCalendar.Set(startCalendar.Get(CalendarField.Year), startCalendar.Get(CalendarField.Month), startCalendar.Get(CalendarField.DayOfMonth), startHour, startMinute, 0);
                                meeting.StartTime = startTimeCalendar;

public static class CustomDateTime{

public static Calendar DateTimeToCalendar(DateTimeOffset date)
        {
            Calendar calendar = new GregorianCalendar(Java.Util.TimeZone.GetTimeZone("UTC"));
            // calendar.TimeInMillis = date.Millisecond;
            calendar.Time =DateTimeToJDKDateTime(date);
          
            return calendar;
        }

 public static Java.Util.Date DateTimeToJDKDateTime(DateTimeOffset date)
        {
            long dateTimeUtcAsMilliseconds = (long)date.ToUniversalTime().Subtract(
                new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
            ).TotalMilliseconds;
            return new Date(dateTimeUtcAsMilliseconds);
        }
}

Please help me its urgent. Thank You.

1 Reply

SG Swathi Gopal Syncfusion Team December 26, 2017 11:45 AM UTC

Hi Ishwor, 
 
Thanks for contacting Syncfusion Support. 
 
Based on the provided information, we suspect that your requirement is to convert Datetime to Calendar and it can be achieved like below, 
 
[c#] 
 
  public static Calendar ConvertToCalendar(DateTime date) 
        {

            Calendar calendar = Calendar.Instance;
            calendar.Set(date.Year, date.Month - 1, date.Day, date.Hour, date.Minute, date.Second);
            return calendar;
        } 
 
 
 
If the provided solution doesn’t meet your requirement, could you please elaborate your query with more information along with sample (if possible). It will be helpful for us to analyze on your requirement and provide a possible solution. We can provide custom assemblies to the customer earlier, once the implementation has done from our side. 
  
Regards, 
Swathi G 


Loader.
Up arrow icon