File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
src/main/java/com/howtodoinjava/core/datetime Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .howtodoinjava .core .datetime ;
2
+
3
+ import java .time .LocalDate ;
4
+ import java .time .format .DateTimeFormatter ;
5
+ import java .time .temporal .IsoFields ;
6
+ import java .time .temporal .TemporalAdjusters ;
7
+
8
+ public class GetQuarterInfo {
9
+
10
+ public static void main (String [] args ) {
11
+
12
+ LocalDate localDate = LocalDate .now ();
13
+
14
+ //What is current quarter
15
+ int currentQuarter = localDate .get (IsoFields .QUARTER_OF_YEAR );
16
+ System .out .println (currentQuarter );
17
+
18
+ String currentQuarterStr = localDate .format (DateTimeFormatter .ofPattern ("QQQQ" ));
19
+ System .out .println (currentQuarterStr );
20
+
21
+ //Current quarter start date and end date
22
+ LocalDate firstDay = localDate .with (IsoFields .DAY_OF_QUARTER , 1L );
23
+ LocalDate lastDay = firstDay .plusMonths (2 ).with (TemporalAdjusters .lastDayOfMonth ());
24
+ System .out .println (firstDay );
25
+ System .out .println (lastDay );
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments