Android examples for java.util:Date Format
Format Date value to string in yyyyMM format
import android.annotation.SuppressLint; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main{ public static String toDateYYYYMM(Date date) { SimpleDateFormat df = new SimpleDateFormat("yyyyMM"); return df.format(date); }//from w w w . ja va 2 s .c o m }