Get current Date in yyyy-MM-dd HH:mm:ss.SSS format - Android java.util

Android examples for java.util:Date

Description

Get current Date in yyyy-MM-dd HH:mm:ss.SSS format

Demo Code

import android.annotation.SuppressLint;
import android.widget.TextView;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main{


    public static String getDateWithMS() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss.SSS");
        return format.format(date);
    }// w w  w  .  jav a2  s  .  c om

}

Related Tutorials