Method Naming Conventions

The Date-Time API offers a rich set of methods within a rich set of classes. The method names are made consistent between classes wherever possible. For example, many of the classes offer a now method that captures the date or time values of the current moment that are relevant to that class. There are from methods that allow conversion from one class to another.

There is also standardization regarding the method name prefixes. Because most of the classes in the Date-Time API are immutable, the API does not include set methods. (After its creation, the value of an immutable object cannot be changed. The immutable equivalent of a set method is with .) The following table lists the commonly used prefixes:

PrefixMethod TypeUse
ofstatic factoryCreates an instance where the factory is primarily validating the input parameters, not converting them.
fromstatic factoryConverts the input parameters to an instance of the target class, which may involve losing information from the input.
parsestatic factoryParses the input string to produce an instance of the target class.
formatinstanceUses the specified formatter to format the values in the temporal object to produce a string.
getinstanceReturns a part of the state of the target object.
isinstanceQueries the state of the target object.
withinstanceReturns a copy of the target object with one element changed; this is the immutable equivalent to a set method on a JavaBean.
plusinstanceReturns a copy of the target object with an amount of time added.
minusinstanceReturns a copy of the target object with an amount of time subtracted.
toinstanceConverts this object to another type.
atinstanceCombines this object with another.