Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Discover the Quarter of a given Date in JAva

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Locale;
public class Demo {
	public static void main(String[] args) {
		LocalDate currentDate = LocalDate.now();
		System.out.println("Current Date = "+currentDate);
		Calendar cal = Calendar.getInstance(Locale.US);
		int month = cal.get(Calendar.MONTH);
		int quarter = (month / 3) + 1;
		System.out.println("Quarter = "+quarter);
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.