常用时间戳订单号,时间日期格式转换,获取当前时间 DateFormat+java 封装常用的时间类(1秒接入)

常用时间戳订单号,时间日期格式转换,封装工具类

Java代码

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


public class DateFormat {
	// 时间格式转换
	public Map<String, Object> dateFormat() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmss");
		
		
		//现在默认当前系统时间
		String nows =  sdf.format(new Date());
		
		
		//订单号
		String order = sdf1.format(new Date())+(int)((Math.random()*9+1)*100000);
		
		String nows2 = sdf1.format(new Date());
		
	
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("now", nows);
			map.put("order ", order );
			map.put("nows2 ", nows2 );
			
			return map;


	}
	
	
}

发布了9 篇原创文章 · 获赞 9 · 访问量 5901

猜你喜欢

转载自blog.csdn.net/my_batis/article/details/103071242