get Now in yyyy_MM_dd_HH_mm_ss underscore format - Android java.util

Android examples for java.util:Date Format

Description

get Now in yyyy_MM_dd_HH_mm_ss underscore format

Demo Code

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main{

    public static String getNow() {
        String formattedDate = "";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss",
                Locale.US);/* w  ww .  j av  a  2s.  co  m*/
        formattedDate = sdf.format(new Date());
        return formattedDate;
    }

}

Related Tutorials