网站开发人才培养目标,二手车网站开发PPT,博客托管服务 wordpress,虚拟机建设网站文章目录String 转成 DateDate 转成 StringString 转成 Timestamp获取系统当前的毫秒数获取系统当前的日期时间毫秒数转成 Timestamp毫秒数转成 DateTimestamp 转成 StringDate 转成 TimestampTimestamp 转成 Datejava.util.Date 转成 java.sql.Date将带T的日期时间转成正常的日…
文章目录String 转成 DateDate 转成 StringString 转成 Timestamp获取系统当前的毫秒数获取系统当前的日期时间毫秒数转成 Timestamp毫秒数转成 DateTimestamp 转成 StringDate 转成 TimestampTimestamp 转成 Datejava.util.Date 转成 java.sql.Date将带T的日期时间转成正常的日期时间String 转成 LocalDateTimeLocalDateTime 转成 DateString 转成 Date
String str 2010/05/04 12:34:23;
DateFormat df new SimpleDateFormat(yyyy/MM/dd HH:mm:ss);
Date date df.parse(str);Date 转成 String
Date date new Date();
DateFormat df new SimpleDateFormat(yyyy/MM/dd HH:mm:ss);
String str df.format(date);String 转成 Timestamp
String str 2011-05-09 11:49:45;// 字符串日期时间格式为yyyy-mm-dd hh:mm:ss
Timestamp timestamp Timestamp.valueOf(str);获取系统当前的毫秒数
System.currentTimeMillis()获取系统当前的日期时间
Date date new Date();毫秒数转成 Timestamp
Timestamp ts new Timestamp(System.currentTimeMillis());毫秒数转成 Date
Date date new Date(System.currentTimeMillis());Timestamp 转成 String
Timestamp ts new Timestamp(System.currentTimeMillis());
String str ts.toString();或者
DateFormat df new SimpleDateFormat(yyyy/MM/dd HH:mm:ss);
Timestamp ts new Timestamp(System.currentTimeMillis());
String str df.format(ts);Date 转成 Timestamp
Date date new Date();
Timestamp ts new Timestamp(date.getTime())Timestamp 转成 Date
Timestamp ts newTimestamp(System.currentTimeMillis());
Date date ts; // Timestamp是Date的子类或者
Timestamp ts new Timestamp(System.currentTimeMillis());
Date date new Date(ts.getTime());java.util.Date 转成 java.sql.Date
java.util.Date date1 new java.util.Date();
java.sql.Date date2 new java.sql.Date(date1.getTime());// 时间会丢失将带T的日期时间转成正常的日期时间
String str 2022-08-13T13:25:35;
str str.replaceAll(T, ) :00String 转成 LocalDateTime
DateTimeFormatter df DateTimeFormatter.ofPattern(yyyy-MM-dd HH:mm:ss);
String str 2022-08-15 13:55:35;
LocalDateTime localDateTime LocalDateTime.parse(str,df);
Systom.out.print(localDateTime);// 日期时间带TLocalDateTime 转成 Date
Date date Date.from(localDateTime.atZone( ZoneId.systemDefault()).toInstant());