Java String to Time getIdByTime(String name)

Here you can find the source of getIdByTime(String name)

Description

get Id By Time

License

Open Source License

Declaration

public static synchronized String getIdByTime(String name) 

Method Source Code


//package com.java2s;
import java.text.Format;

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

public class Main {

    public static synchronized String getIdByTime(String name) {
        return name + "-" + getCurrDate() + "-" + getCurrTime() + "-" + getRandomNumber();
    }// ww w .  j  a v a  2s .  c  om

    public static String getCurrDate() {
        Date date = new Date();
        Format formatter = new SimpleDateFormat("yyyy.MM.dd");
        return formatter.format(date);
    }

    public static String getCurrTime() {
        Date date = new Date();
        Format formatter = new SimpleDateFormat("HH.mm.ss");
        return formatter.format(date);
    }

    public static String getRandomNumber() {
        Random random = new Random();
        String retval = String.valueOf(random.nextInt(100));
        return retval;
    }
}

Related

  1. getDlayDateTime(String playDate, String playTime)
  2. getEndTime(String flag, int value)
  3. getExecutionDateTime(String input)
  4. getExpireTime(String timeStr)
  5. getFormerDate(String dateTime)
  6. getMReportTime(String time)
  7. getSignTime(final String stStr)
  8. getStringWithTime(String str)
  9. getSystemTime(String pattern)