Java LocalDateTime Calculate fastDateTimeWriteHours(LocalDateTime localDateTime)

Here you can find the source of fastDateTimeWriteHours(LocalDateTime localDateTime)

Description

fast Date Time Write Hours

License

Open Source License

Declaration

public static char[] fastDateTimeWriteHours(LocalDateTime localDateTime) 

Method Source Code

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

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class Main {
    public static char[] fastDateTimeWriteHours(LocalDateTime localDateTime) {
        char[] c = new char[13];

        LocalDate localDate = localDateTime.toLocalDate();
        int y = localDate.getYear();
        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) ('-');
        int m = localDate.getMonthValue();
        c[5] = (char) ('0' + (m / 10));
        c[6] = (char) ('0' + (m % 10));
        c[7] = (char) ('-');
        int d = localDate.getDayOfMonth();
        c[8] = (char) ('0' + (d / 10));
        c[9] = (char) ('0' + (d % 10));
        c[10] = (char) ('T');
        LocalTime localTime = localDateTime.toLocalTime();
        int h = localTime.getHour();
        c[11] = (char) ('0' + (h / 10));
        c[12] = (char) ('0' + (h % 10));

        return c;
    }//from  w  w w . j a v a  2  s  . c om
}

Related

  1. converterZoneDatetimeToLocalDateTime( final String date)
  2. currentTimeMillis(LocalDateTime ldt)
  3. DateTime2LocalDateTime(Date datetime)
  4. dateTimeToOleMinutes(LocalDateTime datetime)
  5. dayDuration(LocalDateTime startDateTime, LocalDateTime endDateTime)
  6. getShiftResult(ImmutableMap timexUnitMap, LocalDateTime reference, boolean future)
  7. getStartWeekOfMonth(@Nonnull final LocalDateTime aDT, @Nonnull final Locale aLocale)
  8. getTimePart(final LocalDateTime dateTime)
  9. getZonedDateTime(LocalDateTime dateTime, TimeZone timeZone)