Android examples for java.util:Date Format
get Now in yyyy_MM_dd_HH_mm_ss underscore format
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; } }