Here you can find the source of getDayShort(Date date)
public static int getDayShort(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.HashMap; public class Main { public static final long START_2011 = 1293876000000l; public static HashMap<Integer, Integer> DAYS_2011 = new HashMap<Integer, Integer>(); public static int getDayShort(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(START_2011); Calendar targetCalendar = Calendar.getInstance(); targetCalendar.setTime(date);/* w w w.jav a 2s.c om*/ targetCalendar.set(Calendar.HOUR_OF_DAY, 0); targetCalendar.set(Calendar.MINUTE, 0); targetCalendar.set(Calendar.SECOND, 0); targetCalendar.set(Calendar.MILLISECOND, 0); int daysBetween = 0; int targetYear = targetCalendar.get(Calendar.YEAR); if (calendar.get(Calendar.YEAR) <= targetYear) { if (DAYS_2011.containsKey(targetYear)) { daysBetween += DAYS_2011.get(targetYear); calendar.set(Calendar.YEAR, targetYear); } } while (calendar.before(targetCalendar)) { //todo optimize; calendar.add(Calendar.DAY_OF_MONTH, 1); daysBetween++; } return 1 + daysBetween; } /** * @return day from beginning of 2011 Year * It's NOT the same as ((extract(year from NOW()) - 2011)*365 + extract(doy from NOW())) in database; * As leap years counting. */ public static int getDayShort() { return getDayShort(Calendar.getInstance().getTime()); } }