Java tutorial
//package com.java2s; //License from project: Apache License import android.annotation.SuppressLint; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { @SuppressLint("SimpleDateFormat") public static String getFormattedCurrentDate() { Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate = df.format(c.getTime()); return formattedDate; } }