Java tutorial
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.util.Date; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static int getDayFromDate(String origDate) { DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); Date date; int day = 1; try { date = formatter.parse(origDate); Calendar cal = Calendar.getInstance(); cal.setTime(date); day = cal.get(Calendar.DAY_OF_MONTH); } catch (ParseException e) { e.printStackTrace(); } return day; } }