get Time Stamp in yyyyMMddhhmmssSSS format - Android java.sql

Android examples for java.sql:Timestamp

Description

get Time Stamp in yyyyMMddhhmmssSSS format

Demo Code

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.security.SecureRandom;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class Main{


    public static String getTimeStamp() {

        String rtnStr = null;//from  www.  ja v  a  2 s . c  o m

        String pattern = "yyyyMMddhhmmssSSS";

        try {
            SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern,
                    Locale.KOREA);
            Timestamp ts = new Timestamp(System.currentTimeMillis());

            rtnStr = sdfCurrent.format(ts.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return rtnStr;
    }

}

Related Tutorials