常用时间戳订单号,时间日期格式转换,封装工具类
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;
}
}