Here you can find the source of doy(LocalDate date)
Parameter | Description |
---|---|
date | the date to query |
static int doy(LocalDate date)
//package com.java2s; /**// w w w.j a v a 2 s .c om * Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ import java.time.LocalDate; public class Main { private static final int[] STANDARD = { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; private static final int[] LEAP = { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }; /** * Finds the day-of-year of the date. * <p> * Faster than the JDK method. * * @param date the date to query * @return the day-of-year */ static int doy(LocalDate date) { int[] lookup = (date.isLeapYear() ? LEAP : STANDARD); return lookup[date.getMonthValue()] + date.getDayOfMonth(); } }