package com.vci.common.utility;
|
|
/**
|
* <p>Title: </p>
|
* <p>Description: has two methods, one is to get 36 length guid,
|
* the other is to get 20 length guid.</p>
|
*/
|
public final class ObjectUtility {
|
|
public static final String seperator = "";
|
|
public ObjectUtility() {
|
|
}
|
|
/**
|
* get a new guid which length is 36
|
*
|
* @return string
|
*/
|
public static String getNewObjectID36() {
|
RandomGUID36 newGUID = new RandomGUID36();
|
return newGUID.toString();
|
}
|
|
/**
|
* get a new guid which length is 20
|
*
|
* @param strToken
|
* @return
|
*/
|
public static String getNewObjectID20(String strToken) {
|
RandomGUID20 random = new RandomGUID20();
|
return random.getNewObjectID(strToken);
|
}
|
|
/**
|
* 采用雪花算法创建ID
|
* @return
|
*/
|
public static long getSnowFlakeID() {
|
return SnowFlake.nextId();
|
}
|
|
|
public static long getTimeMillis(Object value) {
|
long times = 0;
|
if (value == null)
|
return times;
|
|
if (value instanceof java.sql.Timestamp) {
|
java.sql.Timestamp ts = (java.sql.Timestamp)value;
|
times = ts.getTime();
|
} else if (value instanceof java.sql.Timestamp) {
|
java.sql.Date date = (java.sql.Date)value;
|
times = date.getTime();
|
} else {
|
times = Long.valueOf(value.toString());
|
}
|
|
return times;
|
}
|
|
}
|