View current date in Java

The following are typical classes used when dealing with date types in Java programming. ― java.util.Date; ― java.text.DateFormat; ― java.text.SimpleDateFormat;

When retrieving using the Date class, you can get the Date object with the current date and time by creating a Date object with no arguments. If you want to format the output format to any format, use SimpleDateFormat class etc.

Date date=new Date();
        
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm");
        
String formattedDate=dateFormat.format(date);
        
System.out.println(formattedDate);

result: スケッチ (7).png

Recommended Posts

View current date in Java
Date manipulation in Java 8
Date processing in Java (LocalDate: Initialization)
How to implement date calculation in Java
Studying Java 8 (date API in java.time package)
Changes in Java 11
Rock-paper-scissors in Java
Output Date in Java in ISO 8601 extended format
How to get the date in java
[java] sort in list
Read JSON in Java
Make Blackjack in Java
Constraint programming in Java
Put java8 in centos7
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
[Java] Date / time operations
Comments in Java source
Azure functions in java
Format XML in Java
Simple htmlspecialchars in Java
Java basic date manipulation
Hello World in Java
View Java Optional Javadoc
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
Zabbix API in Java
POST JSON in Java
What's new in Java 8
Use PreparedStatement in Java
What's new in Java 9,10,11
Parallel execution in Java
java: Add date [Note]
Initializing HashMap in Java
[Java] Date type conversion
Try using RocksDB in Java
Avoid Yubaba's error in Java
Get the next business day after the specified date in JAVA
Get EXIF information in Java
Save Java PDF in Excel
Edit ini in Java: ini4j
Java history in this world
Try calling JavaScript in Java
Try functional type in Java! ①
I made roulette in Java.
Create hyperlinks in Java PowerPoint
Implement two-step verification in Java
Refactoring: Make Blackjack in Java
Topic Analysis (LDA) in Java
NEologd preprocessing in Java neologdn-java
Change java encoding in windows
Java Stream API in 5 minutes
Cannot find javax.annotation.Generated in Java 11
Read standard input in Java
[Java] "T" is included in date type JSON in API response