Duration hashCode()
returns a hash code for this duration.
hashCode
has the following syntax.
public int hashCode()
The following example shows how to use hashCode
.
import java.time.Duration; import java.time.LocalTime; /* w ww . ja v a 2 s .com*/ public class Main { public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON); System.out.println(duration.getSeconds()); System.out.println(duration.hashCode()); } }
The code above generates the following result.