Android examples for java.util:Date Format
get Current Timestamp in yyyy-MM-dd HH:mm:ss format
import android.annotation.SuppressLint; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main{ /**/* ww w .ja va2 s. co m*/ * Get current time include time zone to save to DB * * @return time string */ @SuppressLint("SimpleDateFormat") public static String getCurrentTimestamp() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar .getInstance().getTime()); } }