# Issue with configuring Schedules with Java SDK

**URL:** <https://community.temporal.io/t/issue-with-configuring-schedules-with-java-sdk/13521>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [September 12, 2024, 11:48am UTC](https://community.temporal.io/t/issue-with-configuring-schedules-with-java-sdk/13521 "2024-09-12T11:48:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdswnt](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@kdswnt](https://community.temporal.io/u/kdswnt)\
**Post date:** [September 12, 2024, 11:48am UTC](https://community.temporal.io/t/issue-with-configuring-schedules-with-java-sdk/13521/1 "2024-09-12T11:48:41Z")

</div>

I’m developing functionality where I need to send reminders to users after every 12 hours. I want to configure a schedule such that it’ll initiate a workflow 12 hours after schedule creation time.

**First approach -**  
In the first approach I initiated schedule with `setStartDelay ` of 12 hours. In this case first workflow run was scheduled at 12:00 UTC instead of 12 hours after the schedule creation time.

```java
Schedule schedule = Schedule.newBuilder()
.setAction(
    ScheduleActionStartWorkflow.newBuilder()
        .setWorkflowType(ReminderWorkflow.class)
        .setArguments(workflowInput)
        .setOptions(
            WorkflowOptions.newBuilder()
                .setStartDelay(Duration.ofHours(12))
                .setWorkflowId(referenceId)
                .setTaskQueue(taskQueue)
                .build())
        .build())
.setSpec(ScheduleSpec.newBuilder()
    .setIntervals(Collections.singletonList(new ScheduleIntervalSpec(Duration.ofHours(12))))
    .setTimeZoneName("Asia/Kolkata")
    .build())
.build();

```

Schedule details

```auto
Schedule Created: 2024-09-12 UTC 10:28:32.28

Upcoming Runs as observed from temporal UI
2024-09-12 UTC 12:00:00.00

2024-09-13 UTC 00:00:00.00

2024-09-13 UTC 12:00:00.00

2024-09-14 UTC 00:00:00.00

2024-09-14 UTC 12:00:00.00

```

**Second approach -**  
In second approach I removed the `setStartDelay ` and used `setCalendars`. In this case also the first workflow run was scheduled at 12:00 UTC instead of 12 hours after the schedule creation time. Additionally, second workflow run was scheduled after the 12 hours.

```java
LocalDateTime scheduleStartTime = LocalDateTime.now().plusHours(12);
Schedule schedule = Schedule.newBuilder()
.setAction(
    ScheduleActionStartWorkflow.newBuilder()
        .setWorkflowType(ReminderWorkflow.class)
        .setArguments(workflowInput)
        .setOptions(
            WorkflowOptions.newBuilder()
                .setWorkflowId(referenceId)
                .setTaskQueue(taskQueue)
                .build())
        .build())
.setSpec(ScheduleSpec.newBuilder()
    .setCalendars(
        Collections.singletonList(
            ScheduleCalendarSpec.newBuilder()
                .setDayOfMonth(Collections.singletonList(new ScheduleRange(scheduleStartTime.getDayOfMonth())))
                .setHour(Collections.singletonList(new ScheduleRange(scheduleStartTime.getHour())))
                .setMinutes(Collections.singletonList(new ScheduleRange(scheduleStartTime.getMinute())))
                .setSeconds(Collections.singletonList(new ScheduleRange(scheduleStartTime.getSecond())))
                .build()))
    .setIntervals(Collections.singletonList(new ScheduleIntervalSpec(Duration.ofHours(12))))
    .setTimeZoneName("Asia/Kolkata")
    .build())
.build();

```

Schedule details

```auto
Schedule Created: 2024-09-12 UTC 10:26:28.07

Upcoming Runs as observed from temporal UI
2024-09-12 UTC 12:00:00.00

2024-09-12 UTC 22:26:28.00

2024-09-13 UTC 00:00:00.00

2024-09-13 UTC 12:00:00.00

2024-09-14 UTC 00:00:00.00

```

Also `setTimeZoneName` doesn’t seem to have an impact on the outcome.  
Is there something wrong with the way schedule is configured?
