public class Demo {
public static void main(String[] args) throws ParseException {
//解析时间
// String str="2000-11-11";
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// Date parse = simpleDateFormat.parse(str);
//获取日历对象
// Calendar instance = Calendar.getInstance();
//获取所有的时区的名称
Set<String> availableZoneIds = ZoneId.getAvailableZoneIds();
System.out.println("availableZoneIds = " + availableZoneIds);
//获取当前系统的默认时区
ZoneId zoneId = ZoneId.systemDefault();
System.out.println("zoneId = " + zoneId);
//获取指定的时区
ZoneId of = ZoneId.of("Asia/Pontianak");
System.out.println("of = " + of);
//Instant时间戳
//获取当前时间的Instant对象
Instant now = Instant.now();
System.out.println("now = " + now);
//根据(秒/毫秒/纳秒)获取Instant对象
Instant instant = Instant.ofEpochMilli(0L);
System.out.println("instant = " + instant);
Instant instant1 = Instant.ofEpochSecond(1L);
Instant instant2 = Instant.ofEpochSecond(1L, 10000000000L);
//指定的时区
ZonedDateTime zonedDateTime = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));
System.out.println("zonedDateTime = " + zonedDateTime);
}
private static void method(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss EE");
Date date = new Date();
String format = simpleDateFormat.format(date);
System.out.println("format = " + format);
}
}
包装类:
// 把整数转成二进制,八进制,十六进制
String s = Integer.toBinaryString(100);//转为二进制
System.out.println("s = " + s);
String s1 = Integer.toOctalString(100);//转为八进制
System.out.println("s1 = " + s1);
String s2 = Integer.toHexString(100);//转为十六进制
System.out.println("s2 = " + s2);