Example usage for java.time LocalDateTime format

List of usage examples for java.time LocalDateTime format

Introduction

In this page you can find the example usage for java.time LocalDateTime format.

Prototype

@Override 
public String format(DateTimeFormatter formatter) 

Source Link

Document

Formats this date-time using the specified formatter.

Usage

From source file:com.omertron.slackbot.functions.Meetup.java

/**
 * Format the MeetUp list into a list of Slack Attachments, up to a certain number of days ahead
 *
 * @param daysAhead/*from  ww  w.  ja  v a2  s .co m*/
 * @param detailed
 * @return
 */
public static Map<LocalDateTime, SlackAttachment> getMeetupsDays(int daysAhead, boolean detailed) {
    LocalDate now = LocalDate.now();
    Map<LocalDateTime, SlackAttachment> results = new HashMap<>();

    Period diff;
    for (MeetupDetails md : MEETUPS) {
        // Correct for BST
        LocalDateTime meetTime = md.getMeetupTime().plusHours(1);

        diff = Period.between(now, meetTime.toLocalDate());
        if (diff.getDays() <= daysAhead) {
            LOG.info("Add: Days: {} - {} - {}", diff.getDays(), meetTime.format(DT_FORMAT), md.getName());
            results.put(meetTime, makeSlackAttachment(md, detailed));
        } else {
            LOG.info("Skip: Days: {} - {} - {}", diff.getDays(), meetTime.format(DT_FORMAT), md.getName());
        }
    }

    return results;
}

From source file:org.codelibs.fess.taglib.FessFunctions.java

public static String formatDate(final LocalDateTime date) {
    if (date == null) {
        return StringUtil.EMPTY;
    }/* w  w  w  .j  av a2  s.c  om*/
    return date.format(DateTimeFormatter.ofPattern(Constants.ISO_DATETIME_FORMAT, Locale.ROOT));
}

From source file:io.manasobi.utils.DateUtils.java

public static String convertToString(LocalDateTime dateTime, String pattern) {
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern(pattern);
    return dateTime.format(formatter);
}

From source file:io.manasobi.utils.DateUtils.java

/**
 *  , ? ? , pattern ? ? ?? .<br><br>
 *
 * DateUtils.getNow("yyyy MM dd? hh mm ss") = "2012 04 12? 20 41 50"<br>
 * DateUtils.getNow("yyyy-MM-dd HH:mm:ss") = "2012-04-12 20:41:50"
 *
 * @param pattern  ? ?  ?// www .j  a  v a  2  s. c o  m
 * @return patter ?  ?   
 */
public static String getNow(String pattern) {
    LocalDateTime dateTime = LocalDateTime.now();
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern(pattern);
    return dateTime.format(formatter);
}

From source file:io.manasobi.utils.DateUtils.java

public static String convertToStrKorDate(LocalDateTime dateTime) {
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter
            .ofPattern(KOR_DATE_PATTERN);
    return dateTime.format(formatter);
}

From source file:io.manasobi.utils.DateUtils.java

public static String convertToString(LocalDateTime dateTime) {
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter
            .ofPattern(DATE_TIME_PATTERN);
    return dateTime.format(formatter);
}

From source file:io.manasobi.utils.DateUtils.java

public static String convertToStrKorDateTime(LocalDateTime dateTime) {
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter
            .ofPattern(KOR_DATE_TIME_PATTERN);
    return dateTime.format(formatter);
}

From source file:org.cloud.mblog.utils.FileUtil.java

private static String getDateTypeFileName(LocalDateTime date, String suffix) {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern(FILE_UPLOAD_SUB_IMG_DIR_FMT);
    return date.format(formatter) + "." + suffix;
}

From source file:io.manasobi.utils.DateUtils.java

public static String convertToStrKorDate(String dateStr, String pattern) {
    LocalDateTime dateTime = convertToDateTime(dateStr, pattern);
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter
            .ofPattern(KOR_DATE_PATTERN);
    return dateTime.format(formatter);
}

From source file:io.manasobi.utils.DateUtils.java

public static String convertToStrKorDateTime(String dateTimeStr, String pattern) {
    LocalDateTime dateTime = convertToDateTime(dateTimeStr, pattern);
    java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter
            .ofPattern(KOR_DATE_TIME_PATTERN);
    return dateTime.format(formatter);
}