java: Add date [Note]

Basics :: java: Date addition. Is it easier to use Calendar for java to add dates? There is also a new DateTime in php (also in java).

demojava/demo16/Demo16.java


package demojava.demo16;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Demo16 {
	public static void main(String[] args) {
		Calendar cal = Calendar.getInstance();
		Date now = new Date();
		SimpleDateFormat sm = new SimpleDateFormat("yyyy/MM/dd");
		
		System.out.println(sm.format(now));
		for(int i = 0 ;i <= 31; i++){
			cal.add(Calendar.DAY_OF_MONTH,1);
			System.out.println(sm.format(cal.getTime()));
		}
	}
}

Execution result

2020-10-13_14-36-17.png

Recommended Posts

java: Add date [Note]
Java (add2)
[Java] Internal Iterator Note
[Java] Date / time operations
Java JUnit brief note
[java] Java SE 8 Silver Note
Java basic date manipulation
[Note] Java: String search
[Note] Java: String survey
[Java] Initialize, add, get
My Study Note (Java)
[Java] Date type conversion
(Note) Java classes / variables / methods
[Java] Date Related Term Memo
[Java] [Spring] Spring Boot 1.4-> 1.2 Downgrade Note
Study Java with Progate Note 1
View current date in Java
Add multi-letter watermark to Java Word
Note
[Note] Java Silver SE8 qualification acquired
Java release date and EOL summary
[Java] Points to note with Arrays.asList ()
Date processing in Java (LocalDate: Initialization)
Java Unit Test Library-Artery-Current Date Judgment
Note 1: Elementary, stumbling blocks (java, javascript)
Add Bean Validation with Micronaut (Java)
Add, replace, delete Java PDF images
[Note] Handling of Java decimal point
[MySQL] [java] Receive date and time
My note: Introducing Java to Ubuntu
Add watermark to Java to PDF document
[Java] Date period duplication check sample
[Java] Add WordArt to Word document
Java
Add / remove watermark to Java PowerPoint
Note: Differences from Java as seen from C #
Add index with Java8 Stream.map (tuple version)
How to implement date calculation in Java
Java date data type conversion (Date, Calendar, String)
Studying Java 8 (date API in java.time package)
Pass parameters when debugging vscode java. [Note]
[Java] How to add data to List (add, addAll)
[Beginner] Java method / class / external library [Note 23]
Java SE 8 Silver (Java SE 8 Programmer I) Pass Note
Basic knowledge of Java development Note writing
[Java] How to set the Date time to 00:00:00
Output Date in Java in ISO 8601 extended format
Java 8 to start now ~ Date time API ~
Note: next ・ nextLine (paiza learning Java introduction 9: # 06)
[Note] Cooperation between Java and DB (basic)
Add Document to Azure Search Service (Java)
How to use Java Scanner class (Note)
How to get the date in java
Add footnotes to Word documents in Java
[Java] Get the date with the LocalDateTime class
Add SameSite attribute to cookie in Java