TimeUnit#

The unit that a task's duration and a link's lag are counted in. SchedulingConfig.durationUnit sets the project default. A task overrides it with TaskData.durationUnit, and a link with LinkData.lagUnit.

Declaration#

package org.dhtmlx.plen;

public enum TimeUnit { MINUTE, HOUR, DAY }

Values#

Value Description
MINUTE Working minutes. Amounts are rounded to whole minutes when a date is placed.
HOUR Working hours of 60 minutes. Amounts are rounded to whole minutes when a date is placed.
DAY Working days. A working day of any length counts as one day, and a placed date keeps its time of day. Amounts are rounded to whole days when a date is placed.

There are no week, month or year values.

A duration or lag in these units is working time: non-working time on the calendar doesn't count. TaskData.levelingDelay and Pause positions and lengths use the same unit as elapsed time, where DAY means 24 hours.

Where it's used#

Member Type Meaning
SchedulingConfig.durationUnit TimeUnit Project default. Default: DAY.
TaskData.durationUnit TimeUnit Unit of the task's duration, levelingDelay and pauses. null uses the project default.
LinkData.lagUnit TimeUnit Unit of the link's lag. null uses the project default.
LinkAdd.lagUnit TimeUnit Same as LinkData.lagUnit, for a link added with apply.
LinkUpdate.lagUnit Patch<TimeUnit> Changes the unit of an existing link's lag.

In JSON the values are spelled "minute", "hour" and "day". Decode rejects any other spelling. See Exchange JSON with a client.

Example#

The project counts in days, task 2 counts in hours, and the link's lag is in minutes:

import java.util.List;
import org.dhtmlx.plen.*;

public class TimeUnitExample {
  public static void main(String[] args) throws Exception {
    Moment monday = Moment.fromYmdHm(2026, 4, 6, 8, 0);

    ProjectData data = new ProjectData()
        .withConfig(new SchedulingConfig().withDurationUnit(TimeUnit.DAY))
        .withTasks(List.of(
            new TaskData(Id.num(1)).withStartDate(monday).withDuration(2.0),
            new TaskData(Id.num(2))
                .withStartDate(monday)
                .withDuration(6.0)
                .withDurationUnit(TimeUnit.HOUR)))
        .withLinks(List.of(
            new LinkData()
                .withId(Id.str("a"))
                .withSource(Id.num(1))
                .withTarget(Id.num(2))
                .withLag(30.0)
                .withLagUnit(TimeUnit.MINUTE)));

    ScheduleResult result = Engine.schedule(data, new SolveOptions());
    for (Mutation update : result.updates) {
      System.out.println(update.id + ": " + update.startDate + " - " + update.endDate);
    }
  }
}

Output:

2: 2026-04-08 08:30 - 2026-04-08 15:30

Task 1 takes two working days, Monday and Tuesday. Task 2 starts 30 working minutes after that and runs six working hours on the default 08:00-12:00, 13:00-17:00 calendar.