自动生成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 ...
随机推荐
- node链接mongoDB及封装
// 这个模块中封装所有对数据库的常用操作 const MongoClient = require('mongodb').MongoClient; const assert = require('as ...
- ant DatePicker 中文
方式一:局部设置 import 'moment/locale/zh-cn'; import locale from 'antd/lib/date-picker/locale/zh_CN'; //调用时 ...
- 用Java实现一个二叉树
介绍 使用Java实现一个int值类型的排序二叉树 二叉树 二叉树是一个递归的数据结构,每个节点最多有两个子节点. 通常二叉树是二分查找树,每个节点它的值大于或者等于在它左子树节点上的值,小于或者等于 ...
- leetcode-hard-ListNode-23. Merge k Sorted Lists
mycode 91.2% # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x ...
- LC 889. Construct Binary Tree from Preorder and Postorder Traversal
Return any binary tree that matches the given preorder and postorder traversals. Values in the trave ...
- redis复制集
应用场景:复制集作用的场景问题: 1.解决单点故障 2.读写分离 1.准备两台redis服务器 a) 一台做为注服务器,一台做为从服务器 b) 在从服务器中的redis.conf文件中添加 repli ...
- 数据中心网络架构的问题与演进 — CLOS 网络与 Fat-Tree、Spine-Leaf 架构
目录 文章目录 目录 前文列表 CLOS Networking Switch Fabric 胖树(Fat-Tree)型网络架构 Fat-Tree 拓扑示例 Fat-Tree 的缺陷 叶脊(Spine- ...
- 七十八:flask.Restful之flask-Restful标准化返回参数以及准备数据
对于一个视图函数,可以指定好数据结构和字段用于返回,以后使用ORM模型或者自定义的模型的时候,它会自动获取模型中相应的字段,生成json数据,然后再返回给前端,这需要导入flask_restful.m ...
- 【汇总】数据库提权(mysql、mssql)
日期:2018-04-03 11:46:45 作者:Bay0net 介绍:利用 mssql 的 sa 账号提权.利用 MySQL 的 UDF 提权 0x01.mssql 提权 恢复 xp_cmdshe ...
- android开发过程报错
Unable to start activity ComponentInfo{com.example.zxy.myapp/com.example.zxy.myapp.MainActivity}: an ...