get Current Timestamp in yyyy-MM-dd HH:mm:ss format - Android java.util

Android examples for java.util:Date Format

Description

get Current Timestamp in yyyy-MM-dd HH:mm:ss format

Demo Code

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());
    }

}

Related Tutorials