Format Date value to string in yyyyMM format - Android java.util

Android examples for java.util:Date Format

Description

Format Date value to string in yyyyMM format

Demo Code

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

}

Related Tutorials