List of usage examples for java.time.temporal TemporalAdjusters firstDayOfMonth
public static TemporalAdjuster firstDayOfMonth()
From source file:Main.java
public static void main(String[] args) { LocalDate a = LocalDate.of(2014, 6, 30); LocalDate b = a.with(TemporalAdjusters.firstDayOfMonth()); System.out.println(b);/* w ww .ja v a 2 s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime dateTime = ZonedDateTime.now(); dateTime = dateTime.with(TemporalAdjusters.firstDayOfMonth()); System.out.println(dateTime); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01); LocalDateTime t = a.with(TemporalAdjusters.firstDayOfMonth()); System.out.println(t);// w w w .j a v a2 s.c o m }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 25); // 2014-02-25 // first day of February 2014 (2014-02-01) LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); System.out.println(firstDayOfMonth); }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, Month.JULY, 16); System.out.println(date);//from w w w. j a va 2 s.co m LocalDate firstDayOfJuly = date.with(TemporalAdjusters.firstDayOfMonth()); // 2014-07-01 System.out.println(firstDayOfJuly); LocalDate dateOfFirstMonday = date.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)); // 2014-07-07 System.out.println(dateOfFirstMonday); }
From source file:Main.java
public static void main(String[] args) { LocalDate today = LocalDate.now(); // Temporal adjusters for adjusting the dates System.out.println("First date of this month= " + today.with(TemporalAdjusters.firstDayOfMonth())); LocalDate lastDayOfYear = today.with(TemporalAdjusters.lastDayOfYear()); System.out.println("Last date of this year= " + lastDayOfYear); Period period = today.until(lastDayOfYear); System.out.println("Period Format= " + period); System.out.println("Months remaining in the year= " + period.getMonths()); }
From source file:Main.java
public static void main(String[] argv) { LocalDate today = LocalDate.now(); LocalDate tomorrow = today.plusDays(1); LocalDateTime time = LocalDateTime.now(); LocalDateTime nextHour = time.plusHours(1); System.out.println("today = " + today); System.out.println("1) tomorrow = " + tomorrow + " \n2) tomorrow = " + today.plus(1, DAYS)); System.out.println("local time now = " + time); System.out.println("1) nextHour = " + nextHour + " \n2) nextHour = " + time.plus(1, HOURS)); LocalDate nextWeek = today.plus(1, WEEKS); System.out.println("Date after 1 week : " + nextWeek); LocalDate previousYear = today.minus(1, YEARS); System.out.println("Date before 1 year : " + previousYear); LocalDate nextYear = today.plus(1, YEARS); System.out.println("Date after 1 year : " + nextYear); LocalDate firstDayOfMonth = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()); System.out.println("firstDayOfMonth = " + firstDayOfMonth); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private TimeSeriesCollection createTimeSeriesCollection(final Account account) { List<LocalDate> dates = Collections.emptyList(); if (subAccountCheckBox.isSelected()) { // Getting the dates to calculate final LocalDate start = startDateField.getLocalDate().with(TemporalAdjusters.firstDayOfMonth()); final LocalDate stop = endDateField.getLocalDate().with(TemporalAdjusters.lastDayOfMonth()); dates = DateUtils.getLastDayOfTheMonths(start, stop); TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); // For every month, calculate the total amount for (LocalDate date : dates) { final LocalDate d = date.with(TemporalAdjusters.lastDayOfMonth()); final LocalDate s = date.with(TemporalAdjusters.firstDayOfMonth()); // Get the total amount for the account and every sub accounts for the specified date // and include it in the chart t.add(new Month(DateUtils.asDate(date)), calculateTotal(s, d, account, account.getCurrencyNode())); }/*from w w w.ja va 2 s . c o m*/ return new TimeSeriesCollection(t); } int count = account.getTransactionCount(); if (count > 0) { LocalDate start = account.getTransactionAt(0).getLocalDate(); LocalDate stop = account.getTransactionAt(count - 1).getLocalDate(); dates = DateUtils.getLastDayOfTheMonths(start, stop); } TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); AccountType type = account.getAccountType(); for (LocalDate localDate : dates) { // get balance for the whole month LocalDate d = localDate.with(TemporalAdjusters.lastDayOfMonth()); LocalDate s = localDate.with(TemporalAdjusters.firstDayOfMonth()); BigDecimal balance = AccountBalanceDisplayManager.convertToSelectedBalanceMode(type, account.getBalance(s, d)); t.add(new Month(DateUtils.asDate(localDate)), balance); } return new TimeSeriesCollection(t); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChartCompare.java
private TimeSeriesCollection createTimeSeriesCollection(final Account account, final Account a2) { //always use this method //if (subAccountCheckBox.isApproved()) { // Getting the dates to calculate LocalDate start = startDateField.getLocalDate().with(TemporalAdjusters.firstDayOfMonth()); LocalDate stop = endDateField.getLocalDate().with(TemporalAdjusters.lastDayOfMonth()); List<LocalDate> list = DateUtils.getLastDayOfTheMonths(start, stop); TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); TimeSeries t2 = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); // For every month, calculate the total amount for (final LocalDate localDate : list) { final LocalDate d = localDate.with(TemporalAdjusters.lastDayOfMonth()); final LocalDate s = localDate.with(TemporalAdjusters.firstDayOfMonth()); // Get the total amount for the account and every sub accounts // for the specified date //BigDecimal bd_TotalAmount = calculateTotal(s, d, account, account.getCurrencyNode()); BigDecimal bd_TotalAmount = calculateTotal(s, d, account, subAccountCheckBox.isSelected(), account.getCurrencyNode()); // Include it in the graph t.add(new Month(DateUtils.asDate(localDate)), totalModulus(bd_TotalAmount, account.getAccountType())); if (jcb_compare.isSelected()) { bd_TotalAmount = calculateTotal(s, d, a2, subAccountCheckBox.isSelected(), account.getCurrencyNode()); t2.add(new Month(DateUtils.asDate(localDate)), totalModulus(bd_TotalAmount, a2.getAccountType())); }/* w w w .ja v a2 s . com*/ } TimeSeriesCollection tsc = new TimeSeriesCollection(); tsc.addSeries(t); if (jcb_compare.isSelected()) { tsc.addSeries(t2); } return tsc; /* return new TimeSeriesCollection(t); } int count = account.getTransactionCount(); if (count > 0) { Date start = account.getTransactionAt(0).getDate(); Date stop = account.getTransactionAt(count - 1).getDate(); list = DateUtils.getLastDayOfTheMonths(start, stop); } TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); AccountType type = account.getAccountType(); for (Date aList : list) { // get balance for the whole month Date d = DateUtils.getLastDayOfTheMonth(aList); Date s = DateUtils.getFirstDayOfTheMonth(aList); BigDecimal balance = AccountBalanceDisplayManager.convertToSelectedBalanceMode(type, account.getBalance(s, d)); t.add(new Month(aList), balance); } return new TimeSeriesCollection(t); */ }