GUID Generate with UUID and current time - Android java.util

Android examples for java.util:UUID

Description

GUID Generate with UUID and current time

Demo Code

import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;
import java.util.regex.Pattern;

public class Main{

    public static String GenerateGUID(int length) {
        UUID uuid = UUID.randomUUID();
        SimpleDateFormat sDateFormat = new SimpleDateFormat(
                "yyyyMMddhhmmss");
        String date = sDateFormat.format(new java.util.Date());
        return date + uuid.toString().substring(0, 7)
                + randomString(length);//from w w  w  .ja  v a2s .c  o m
    }

}

Related Tutorials