Example Analysis of date Type of string Interchange in java
Editor to share with you the java string interchange date type example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
String interchange date type
Package com.shxt.demo02; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class Demo18 {public static void main (String [] args) {LocalDateTime date = LocalDateTime.now (); DateTimeFormatter format1 = DateTimeFormatter.ofPattern ("yyyy/MM/dd HH:mm:ss"); / / date transfer string String str = date.format (format1) System.out.println ("date to string:" + str); DateTimeFormatter format2 = DateTimeFormatter.ofPattern ("yyyy/MM/dd HH:mm:ss"); / / string conversion date LocalDate date2 = LocalDate.parse (str,format2); System.out.println ("date type:" + date2) }} the above is all the contents of the article "sample Analysis of string Interchange date types in java". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!