我正在使用iCalender API以JAVA方式發送會議請求。目前它對於IST時區正常工作,但在CST/CDT或任何其他時區中部署相同的應用程序時,它會在生成會議請求時在Outlook中顯示錯誤的時間。Outlook請求在IST以外的時區顯示錯誤時間
E.g.我正在生成今天的展望請求,開始時間爲上午10點,結束時間爲上午11點。發送Outlook請求時,它將分別顯示上午11:30至下午12:30作爲開始時間和結束時間。
請看下面是我如何設置請求日曆內容的代碼。
private BodyPart buildCalendarPart() throws Exception {
BodyPart calendarPart = new MimeBodyPart();
TimeZone timezone = TimeZone.getDefault();
long offset = timezone.getOffset(Calendar.ZONE_OFFSET);
Calendar startTime = Calendar.getInstance();
startTime.setTime(taskDTO.getStartDate());
startTime.set(Calendar.HOUR_OF_DAY, 0);
startTime.set(Calendar.MINUTE, 0);
startTime.set(Calendar.SECOND, 0);
if(taskDTO.getStartTimeHrs().equals(12)) {
startTime.set(Calendar.HOUR, 0);
} else {
startTime.set(Calendar.HOUR, taskDTO.getStartTimeHrs());
}
startTime.set(Calendar.MINUTE, taskDTO.getStartTimeMins());
startTime.set(Calendar.SECOND, 0);
if(taskDTO.getStartTimeampm().equalsIgnoreCase(ApplicationConstant.AM))
startTime.set(Calendar.AM_PM,Calendar.AM);
else
startTime.set(Calendar.AM_PM,Calendar.PM);
System.out.println("Start Date :"+startTime.getTime().toString());
Calendar endTime = Calendar.getInstance();
endTime.setTime(taskDTO.getDueDate());
endTime.set(Calendar.HOUR_OF_DAY, 0);
endTime.set(Calendar.MINUTE, 0);
endTime.set(Calendar.SECOND, 0);
if(taskDTO.getEndTimeHrs().equals(12)){
endTime.set(Calendar.HOUR, 0);
}else{
endTime.set(Calendar.HOUR, taskDTO.getEndTimeHrs());
}
endTime.set(Calendar.MINUTE, taskDTO.getEndTimeMins());
endTime.set(Calendar.SECOND, 0);
if(taskDTO.getEndTimeampm().equalsIgnoreCase(ApplicationConstant.AM))
endTime.set(Calendar.AM_PM, Calendar.AM);
else
endTime.set(Calendar.AM_PM, Calendar.PM);
Date startDate = startTime.getTime();
Date endDate = endTime.getTime();
iCalendarDateFormat.setTimeZone(timezone);
//check the icalendar spec in order to build a more complicated meeting request
String calendarContent =
"BEGIN:VCALENDAR\n" +
"METHOD:REQUEST\n" +
"PRODID: BCP - Meeting\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"DTSTAMP:" + iCalendarDateFormat.format(startDate) + "\n" +
"DTSTART:" + iCalendarDateFormat.format(startDate)+ "\n" +
"DTEND:" + iCalendarDateFormat.format(endDate)+ "\n" +
"SUMMARY:Created New Task\n" +
"UID:" + taskDTO.getTaskID() + "\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:MAILTO:"+taskDTO.getLoggedInUserEmailID()+"\n" +
"ORGANIZER:MAILTO:"+taskDTO.getLoggedInUserEmailID()+"\n" +
"SEQUENCE:0\n" +
"PRIORITY:5\n" +
"CLASS:PUBLIC\n" +
"STATUS:CONFIRMED\n" +
"TRANSP:OPAQUE\n" +
"BEGIN:VALARM\n" +
"ACTION:DISPLAY\n" +
"DESCRIPTION:REMINDER\n" +
"TRIGGER;RELATED=START:-PT00H15M00S\n" +
"END:VALARM\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
calendarPart.addHeader("Content-Class", "urn:content-classes:calendarmessage");
calendarPart.setContent(calendarContent, "text/calendar;method=CANCEL");
return calendarPart;
}
請讓我知道如果你有相同的
感謝任何輸入提前!
感謝您的feedback.currently我使用下面的時間格式private static SimpleDateFormat iCalendarDateFormat = new SimpleDateFormat(「yyyyMMdd'T'HHmm'00'」);我仍然面臨這個問題。當我在IST創建CST時區和受讓人的會議請求時,它正在向我顯示當地會議的正確時間,但是它甚至不支持CST。 – user2055427