Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JGraph
>
Tutorial
> Create appointment (event)
The following example shows you how to create an appointment (event).
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import com.independentsoft.graph.ContentType; import com.independentsoft.graph.DateTimeTimeZone; import com.independentsoft.graph.GraphClient; import com.independentsoft.graph.GraphException; import com.independentsoft.graph.ItemBody; import com.independentsoft.graph.Location; import com.independentsoft.graph.LocationType; import com.independentsoft.graph.calendars.Event; import com.independentsoft.graph.users.UserId; public class Test { 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 startTime = dateFormat.parse("2024-10-25 16:00:00"); Date endTime = dateFormat.parse("2024-10-25 18:00:00"); DateTimeTimeZone start = new DateTimeTimeZone(startTime, "Pacific Standard Time"); DateTimeTimeZone end = new DateTimeTimeZone(endTime, "Pacific Standard Time"); ItemBody body = new ItemBody("Body text can be html or plain text. We set it now as a plain text.", ContentType.TEXT); Location location = new Location(); location.setDisplayName("Office 123"); location.setType(LocationType.CONFERENCE_ROOM); Event appointment = new Event(); appointment.setSubject("Development meeting"); appointment.setBody(body); appointment.setStart(start); appointment.setEnd(end); appointment.setLocation(location); Event createdAppointment = client.createEvent(appointment, new UserId("info@independentsoft.onmicrosoft.com")); System.out.println("Id = " + createdAppointment.getId()); } catch (ParseException e) { System.out.println(e.getMessage()); } catch (GraphException e) { System.out.println(e.getCode()); System.out.println(e.getMessage()); } } }
Need help? Ask our developers:
Name*
Email*
Message*