Java Calendar Year getDecimalYear(Calendar calendar)

Here you can find the source of getDecimalYear(Calendar calendar)

Description

Returns the year of the calendar object as a decimal value.

License

Open Source License

Declaration

public static double getDecimalYear(Calendar calendar) 

Method Source Code

//package com.java2s;
/**/*from  w  ww . j a v  a 2 s .c  o m*/
 * Copyright (c) 2010-2017 by the respective copyright holders.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

import java.util.Calendar;

public class Main {
    /**
     * Returns the year of the calendar object as a decimal value.
     */
    public static double getDecimalYear(Calendar calendar) {
        return calendar.get(Calendar.YEAR)
                + (double) calendar.get(Calendar.DAY_OF_YEAR) / calendar.getActualMaximum(Calendar.DAY_OF_YEAR);
    }
}

Related

  1. calendarFor(final int year, final int month, final int day, final int hour, final int minute)
  2. calendarFor(int day, int month, int year)
  3. calendarOf(int year, int month, int day, int hour, int minute, int second, int millis)
  4. copyYearMonthDay(Calendar destCal, Calendar sourceCal)
  5. createAndValidateCalendar(int month, int day, int year)
  6. getFiscalYear(Calendar calendar)
  7. getIntYear(Calendar c)
  8. getLastYear(Calendar cal)
  9. getStartOfWeekCalendar(final int year, final int weekOfYear, final Locale locale)