Format Date to String in yyyyMM format - Android java.util

Android examples for java.util:Date Format

Description

Format Date to String in yyyyMM format

Demo Code

import android.util.Log;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Main{

    public static String dateToStr(java.util.Date dateDate) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
        String dateString = formatter.format(dateDate);
        return dateString;
    }/*ww  w. j a va 2  s. c o m*/

}

Related Tutorials