Here you can find the source of getDayFromYear(String year)
public static int getDayFromYear(String year)
//package com.java2s; /*// w w w . j a v a2 s. com * Copyright 2012-2014 sammyun.com.cn. All rights reserved. * Support: http://www.sammyun.com.cn * License: http://www.sammyun.com.cn/license */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { private static String year_format = "yyyy"; public static int getDayFromYear(String year) { SimpleDateFormat format = new SimpleDateFormat(year_format); Date date; int day = 0; try { date = format.parse(year); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); day = calendar.getActualMaximum(Calendar.DAY_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } return day; } }