Java LocalDate Calculate fastDateWriteWeeks(LocalDate localDate)

Here you can find the source of fastDateWriteWeeks(LocalDate localDate)

Description

fast Date Write Weeks

License

Open Source License

Declaration

public static char[] fastDateWriteWeeks(LocalDate localDate) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.time.LocalDate;

import java.time.temporal.TemporalField;
import java.time.temporal.WeekFields;

import java.util.Locale;

public class Main {
    private static final TemporalField weekOfYear = WeekFields.of(Locale.GERMANY).weekOfWeekBasedYear();
    private static final TemporalField yearOfWeek = WeekFields.of(Locale.GERMANY).weekBasedYear();

    public static char[] fastDateWriteWeeks(LocalDate localDate) {
        char[] c = new char[7];
        int y = localDate.get(yearOfWeek);
        c[0] = (char) ('0' + y / 1000);
        c[1] = (char) ('0' + ((y % 1000) / 100));
        c[2] = (char) ('0' + ((y % 100) / 10));
        c[3] = (char) ('0' + (y % 10));
        c[4] = (char) ('W');
        int w = localDate.get(weekOfYear);
        c[5] = (char) ('0' + (w / 10));
        c[6] = (char) ('0' + (w % 10));
        return c;
    }//w  ww .jav  a 2  s  .com
}

Related

  1. convertLocalDateToDatabaseDateString(LocalDate localDate)
  2. dateToSystemLocalDate(Date d)
  3. daysAgo(LocalDate pastDate)
  4. doy(LocalDate date)
  5. fastDateWrite(LocalDate localDate)
  6. getAge(LocalDate birthday)
  7. getAge(LocalDate birthDay)
  8. getDate(ChronoLocalDate date)
  9. getDate(Console console, Function validator)