Format String Date By passed in Format - Android java.util

Android examples for java.util:Date Format

Description

Format String Date By passed in 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 getStringDateByFormat(String format) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        String dateString = formatter.format(currentTime);
        return dateString;
    }/*from w w w.  j  a  va 2s .  c  om*/

}

Related Tutorials