Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy-MM-dd"); public static int getDayOFYear(String date) { try { Date parse = yearFormat.parse(date); Calendar instance = Calendar.getInstance(); instance.setTime(parse); return instance.get(Calendar.DAY_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } return 0; } }