Fundamentals‎ > ‎

Expressing Duration


JavaFX supports the notion of duration as a fundamental type in the language.  The type Duration is used anywhere a unit of time length is needed.  For instance, duration is heavily used in the JavaFX animation API to express the length of animated segments. his type represent a unit of time. Duration literals can be expressed with several units include ms, s, m, and h for millisecond, second, minute, hour respectively. Here are some examples of literals:

12ms
4s
12h
0.5m

As a value type, durations can participate in expressions

var aDay = 12h + (12 * ( 1000ms * 60 * 60 ));

var halfDay = aDay / 12;


The materials on this website represent a small sample of content loosely based on the book JavaFX Application Development Cookbook.  The book offers far more content with over 80 recipes covering a range of topics from basics to advanced concepts.  

Buy the Book

You can get your copy of the book directly from the publisher. Click here to order!