自动生成ID
public class IdUtil {
/**
*
* @return 返回时间id,类似于20191217195622
*/
public static String timeId(){
Date date=new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
return dateFormat.format(date);
}
/**
*
* @return 返回带-的id
*/
public static String _UID(){
String id= UUID.randomUUID().toString();
return id;
}
/**
*
* @return 返回不带-的id
*/
public static String UID(){
String id= UUID.randomUUID().toString().replaceAll("-","");
return id;
}
/**
* 获取tLongTime 当前时间的毫秒数
* @return
*/
public static String getLongTimeId(){
long longValue =System.currentTimeMillis();
return String.valueOf(longValue);
}
/**
* 判断字符串是否为空
* @param str
* @return
*/
public static String nullutil(String str){
if(str==null){
return str="0";
}
return str;
}
}
自动生成ID的更多相关文章
- Solr4.0 如何配置使用UUID自动生成id值
原文链接http://blog.csdn.net/keepthinking_/article/details/8501058#comments 最近学习了Lucene,随便也学习了Solr,Solr规 ...
- Solr自动生成ID
在Solr中,每一个索引,都要有一个唯一的ID,类似于关系型数据库表中的主键.为了方便创建索引,需要配置自动生成的ID,即UUID. 一.配置schema.xml文件 添加uuid字段类型,修改字段i ...
- mybatis多表查询,自动生成id
主要是在配置文件中,配置好所要包含的字段. 类关系:account----role,1对1 account包含role类 java类: public class Account{ private In ...
- ASP.NET 4.0 ListView等容器控件中获取ClientID值与HTML中自动生成ID字符串不一样问题。
ASP.NET 4.0 中 ClientIDMode的属性 可以设置获取不同ID格式的值. 项目中遇到的问题: 1.ListView1 ItemDataBound事件中,获取ClientID结果与自动 ...
- Elasticsearch 索引文档如何使用自动生成 Id?
一个文档的 _index . _type 和 _id 唯一标识一个文档. 我们可以提供自定义的 _id 值,或者让 index API 自动生成. 如果你的数据没有自然的 ID, Elasticsea ...
- oracle中利用trigger,sequence自动生成ID
http://zhanghong.iteye.com/blog/865937 1. 首先创建数据库表 SQL> create table customer( 2 id number(8) no ...
- 系统自动生成ID(比UUID.radom().tostring()要好看)
public class test1 { public static void main(String[] args) { char[] para = {'A','B','C','D','E','F' ...
- MySQL 之 数据库自动生成ID格式化编号(字符串格式化填充/拼接/时间)
# 用户账号:1-4位:入职年份:5-6位:入职月份:7-11位:员工入职顺序号 select concat( date_format(now(),'%Y'), date_format(now(),' ...
- ES批量索引写入时的ID自动生成算法
对bulk request的处理流程: 1.遍历所有的request,对其做一些加工,主要包括:获取routing(如果mapping里有的话).指定的timestamp(如果没有带timestamp ...
随机推荐
- 关于vue.js element ui 表单验证 this.$refs[formName].validate()的问题
方法使用前需了解: 来自”和“小编的小提示: 首先打印一下this.$refs[formName],检查是否拿到了正确的需要验证的form. 其次在拿到了正确的form后,检查该form上添加 ...
- hbase hbck
Number of Tables: 7Number of live region servers: 3Number of dead region servers: 0Number of empty R ...
- IDEA:Process finished with exit code -1073741819 (0xC0000005)
出门左转:https://www.cnblogs.com/virgosnail/p/10335224.html
- Java-UncaughtExceptionHandler 捕获线程异常
实现 UncaughtExceptionHandler 类,重写 uncaughtException 方法. public class MyUncaughtExceptionHandler imple ...
- ftp列出具体目录的所有目录,和目录按照文件类型列出
package com.haiyisoft.cAssistantWeb.util; import java.io.IOException; import java.io.PrintWriter; im ...
- jxbrowser 实现自定义右键菜单
https://blog.csdn.net/shuaizai88/article/details/73743691 public static void main(String[] args) { J ...
- Hibernate3核心API-SchemaExport类
- Message 消息提示
常用于主动操作后的反馈提示.与 Notification 的区别是后者更多用于系统级通知的被动提醒. 基础用法 从顶部出现,3 秒后自动消失. Message 在配置上与 Notification 非 ...
- 八十:memcached之安装与参数
Memcached是一个高并发的内存键值对缓存系统,它的主要作用是将数据库查询结果,内容,以及其它一些耗时的计算结果缓存到系统内存中,从而加速Web应用程序的响应速度. 官网:http://memca ...
- Linux 服务器基本优化
一:修改ulimit数 vi /etc/security/limits.conf 添加如下行: * soft noproc 65535 * hard noproc 65535 * soft nofil ...