How to get the current time by Java
and convert it into java.sql.date format.
long l = System.currentTimeMillis();
//new date pair
Date date = new Date(l);
//convert to date output format
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(dateFormat.format(date));
String response = dateFormat.format(date).replaceAll("[[\\s-:punct:]]","");
System.out.println("response="+response);
2021-05-07 09:35:47
response=202105
Read More:
- [Solved] Flowable Start Error: ClassCastException: java.time.LocalDateTime cannot be cast to java.lang.String
- Set the default time to the current value in MySQL
- [Solved] Error attempting to get column ‘xxxx_time‘ from result set. Cause: java.sql.SQLFeatureNotSupportedEx
- Error attempting to get column time from result set. Cause: java.sql.SQLFe
- The shell gets the current time of the system and formats it
- Shell gets the current time of the system and formats it
- Linux view current date and time
- Local date time conversion in java8
- In SQLite database, set the default value for the field as the current time
- How to display the Chinese name and installation time of installed software in snmp4j walk Windows
- ‘Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- The time of the time database displayed by the front end is inconsistent
- After switching the tidb database, an error could not commit JDBC transaction appears from time to time
- When calling time module – time / datetime in wxPython, an error is reported. Valueerror: unknown locale: zh cn
- MySQL will delete the data minutes before the current time
- How to compare the time in two TimeStamp format?
- [Solved] Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date‘;
- Common shell (1): shell gets the current time stamp of the system
- How to Close the Current Form in JAVA Swing
- [Solved] SpringBoot Date Convert Error: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime`