Java tutorial
//package com.java2s; import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { @SuppressLint("SimpleDateFormat") public static Date getDateFromString(int year, int month) { String dateString = year + "-" + (month > 9 ? month : ("0" + month)) + "-01"; Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); date = sdf.parse(dateString); } catch (ParseException e) { System.out.println(e.getMessage()); } return date; } }