generate id menggunakan simpledateformat

Bermain lagi sama SimpleDateFormat

q> Yuk membuat generated id menggunakan SimpleDateFormat

package com.ahmada;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Util {

public static void main (String [] args){

System.out.println("id "+getId());

}

public static String getId(){
SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssS");
return sdf.format(new Date());
}

}

q> Jalankan

id 130108154730414

Keterangan ::

q> yy menampilkan tahun (2 angka di belakang)
q> MM menampilkan bulan
q> dd menampilkan tanggal hari
q> HH menampilkan jam
q> mm menampilkan menit
q> ss menampilkan detik
q> S menampilan mili detik

q> Keep Coding !

Published by

saifiahmada

Begin a big Process with a bit trying

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s