Get current date and time as a string in yyMMdd-HHmm format. Used for naming backup files. - Android java.util

Android examples for java.util:Date Format

Description

Get current date and time as a string in yyMMdd-HHmm format. Used for naming backup files.

Demo Code

import android.util.Log;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main{

    /**/*from ww  w  . ja v  a  2  s.  c o m*/
     * Get current date and time as a string. Used for naming backup files.
     */
    public static String getDateForExport() {
        DateFormat df = new SimpleDateFormat("yyMMdd-HHmm");
        return df.format(new Date());
    }

}

Related Tutorials