Java LocalDateTime to localDateTimeToString(LocalDateTime value)

Here you can find the source of localDateTimeToString(LocalDateTime value)

Description

localDateTimeToString, This will return the supplied LocalDateTime as a string.

License

Open Source License

Declaration

public static String localDateTimeToString(LocalDateTime value) 

Method Source Code


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

import java.time.*;

public class Main {
    /**//from w w w. j  a  va2s.c o m
     * localDateTimeToString, This will return the supplied LocalDateTime as a string. If the value
     * is null, this will return the value of emptyTimeString. Time values will be output in the
     * same format as LocalDateTime.toString().
     *
     * Javadocs from LocalDateTime.toString():
     *
     * Outputs this date-time as a {@code String}, such as {@code 2007-12-03T10:15:30}.
     * <p>
     * The output will be one of the following ISO-8601 formats:
     * <ul>
     * <li>{@code uuuu-MM-dd'T'HH:mm}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSS}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSSSS}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS}</li>
     * </ul>
     * The format used will be the shortest that outputs the full value of the time where the
     * omitted parts are implied to be zero.
     */
    public static String localDateTimeToString(LocalDateTime value, String emptyTimeString) {
        return (value == null) ? emptyTimeString : value.toString();
    }

    /**
     * localDateTimeToString, This will return the supplied LocalDateTime as a string. If the value
     * is null, this will return an empty string (""). Time values will be output in the same format
     * as LocalDateTime.toString().
     *
     * Javadocs from LocalDateTime.toString():
     *
     * Outputs this date-time as a {@code String}, such as {@code 2007-12-03T10:15:30}.
     * <p>
     * The output will be one of the following ISO-8601 formats:
     * <ul>
     * <li>{@code uuuu-MM-dd'T'HH:mm}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSS}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSSSS}</li>
     * <li>{@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS}</li>
     * </ul>
     * The format used will be the shortest that outputs the full value of the time where the
     * omitted parts are implied to be zero.
     */
    public static String localDateTimeToString(LocalDateTime value) {
        return (value == null) ? "" : value.toString();
    }
}

Related

  1. getMillis(LocalDateTime time)
  2. getMinuteOfDay(LocalDateTime ldt)
  3. getSecondsSinceJavaEpoch(LocalDateTime localDateTime)
  4. localDateTimeToDate(LocalDateTime ldt)
  5. localDateTimeToEpochMillis(TemporalAccessor temporal)
  6. localDateTimeToTimestamp(LocalDateTime ldt)
  7. longTOLocalDateTime(long minDate)
  8. luisDate(LocalDateTime date)
  9. millisToLocalDateTime(Long inMillis)