==============================================持续更新中==============================================
1.时间格式转换
1.1时间的各种格式
1.1 自定义字符串时间格式 "YYYY-MM-DD HH:mm:ss" 示例: "2021-01-05 13:50:55"
1.2 new Date "week month dayth hour:min:sec CST year" 示例: "Tue Jan 05 13:49:22 CST 2021"
1.3 时间戳 “unix时间戳是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒” "1609825854000"
Date格式转时间戳
long time = new Date().getTime();
时间戳转Date格式(其中格式可以自定义,需要时分秒,或者只需要日期)其中"yyyy-MM-dd HH:mm:ss" 代表着24小时计时,"yyyy-MM-dd hh:mm:ss"表示12小时计时
long time = new Date().getTime();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
simpleDateFormat.format(time);
System.out.println(simpleDateFormat.format(time));
2.各种格式, 如 Integer、Long、Double ;转 String
2.1 String 与 Integer 互转
2.1.1 String 转 Integer
Integer aa = Integer.parseInt("12345");
2.1.2 Integer 转 String(推荐使用String.valueOf(),如果后续需要进行数据加工,则加上非空判断StringUtil.isEmpty() ,toString() 容易报空指针这也是程序员BUG最多的地方)
String bb = String.valueOf(aa);
String cc = (String)aa;
String dd = aa.toString();
附上jdk中String.valueOf()源码:所以,当需要转的对象是null时,则会返回“null” 字符串。不会报错。
public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString();
}
2.2.1 String 转 Long
Long aa = Long.parseLong("12345");
本地修改了hosts 刷新DNS解析
cmd 输入
ipconfig /flushdns
Nacos 在windows系统上startup.cmd启动报错。windows 启动与linux 启动报错
Dubbo+Nacos
部分报错日志
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
Caused by: java.net.UnknownHostException: jmenv.tbsite.net
cmd到bin目录下。输入启动命令
startup.cmd -m standalone