Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JGraph
>
Tutorial
> Update appointment - Reschedule for tomorrow
Update Start and End time to move the appointment for tomorrow.
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; import com.independentsoft.graph.DateTimeTimeZone; import com.independentsoft.graph.GraphClient; import com.independentsoft.graph.GraphException; import com.independentsoft.graph.queryoptions.And; import com.independentsoft.graph.queryoptions.IsGreaterThanOrEqualTo; import com.independentsoft.graph.queryoptions.IsLessThanOrEqualTo; import com.independentsoft.graph.queryoptions.Query; import com.independentsoft.graph.calendars.Event; import com.independentsoft.graph.calendars.EventPropertyName; import com.independentsoft.graph.users.UserId; public class Console { public static void main(String[] args) { try { GraphClient client = new GraphClient(); client.setClientId("63333333-209e-454e-b7bd-55a4d201270f"); client.setTenant("independentsoft.onmicrosoft.com"); client.setClientSecret("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date startTime1 = dateFormat.parse("2024-03-04 10:00:00"); Date startTime2 = dateFormat.parse("2024-03-04 12:00:00"); IsGreaterThanOrEqualTo condition1 = new IsGreaterThanOrEqualTo(EventPropertyName.START_TIME, startTime1); IsLessThanOrEqualTo condition2 = new IsLessThanOrEqualTo(EventPropertyName.START_TIME, startTime2); Query query = new Query(); query.setTop(999); query.setFilter(new And(condition1, condition2)); List
appointments = client.getEvents(new UserId("info@independentsoft.onmicrosoft.com"), query); for (int i = 0; i < appointments.size(); i++) { Calendar cal1 = Calendar.getInstance(); cal1.setTime(appointments.get(i).getStart().getTime()); cal1.add(Calendar.DAY_OF_MONTH, 1); Date newStartTime = cal1.getTime(); Calendar cal2 = Calendar.getInstance(); cal2.setTime(appointments.get(i).getEnd().getTime()); cal2.add(Calendar.DAY_OF_MONTH, 1); Date newEndTime = cal2.getTime(); Event tempAppointment = new Event(); tempAppointment.setId(appointments.get(i).getId()); //important tempAppointment.setStart(new DateTimeTimeZone(newStartTime)); tempAppointment.setEnd(new DateTimeTimeZone(newEndTime)); Event updatedAppointment = client.updateEvent(tempAppointment, new UserId("info@independentsoft.onmicrosoft.com")); } } catch (GraphException e) { System.out.println(e.getCode()); System.out.println(e.getMessage()); e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*