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:Main.java

public static String getDBValueFromLocalDateTime(LocalDateTime start) {
    if (start != null) {
        return start.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
    } else {//from w  w  w .  j  av a  2s . co  m
        return null;
    }
}

From source file:Main.java

public static String formatDateTime(LocalDateTime dateTime) {
    String text = "";
    if (dateTime != null) {
        return dateTime.format(FMT);
    }//ww  w. ja v  a 2s  .  c  o  m
    return text;
}

From source file:edu.psu.swe.scim.spec.protocol.filter.AttributeComparisonExpression.java

public static String toDateTimeString(LocalDateTime ldt) {
    return ldt.format(DateTimeFormatter.ISO_DATE_TIME);
}

From source file:com.fizzed.stork.deploy.DeployHelper.java

static public String toVersionDateTime(long millis) {
    Instant instant = Instant.ofEpochMilli(millis);
    LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
    return ldt.format(versionDateTimeFormatter);
}

From source file:com.fizzed.stork.deploy.DeployHelper.java

static public String toFriendlyDateTime(long millis) {
    Instant instant = Instant.ofEpochMilli(millis);
    LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.UTC);
    return ldt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}

From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java

public static String getString(final LocalDateTime dateTime, final DateTimeFormatter formatter) {
    return dateTime != null ? dateTime.format(formatter) : null;
}

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

/**
 * Convert MeetupDetails into a SlackAttachment
 *
 * @param meetupDetails/* w  ww . ja  v a 2 s .c  o m*/
 * @param detailed
 * @return
 */
private static SlackAttachment makeSlackAttachment(MeetupDetails meetupDetails, boolean detailed) {
    SlackAttachment sa = new SlackAttachment();
    sa.addMarkdownIn("text");
    sa.setColor("good");
    sa.setTitle(meetupDetails.getName());
    sa.setTitleLink(meetupDetails.getLink());
    sa.setThumbUrl("https://secure.meetupstatic.com/photos/event/4/9/1/c/global_453258716.jpeg");

    if (detailed) {
        sa.setText(reformatDescription(meetupDetails.getDescription()));
        sa.addField("Duration", String.format("%1$d hour(s)", meetupDetails.getDuration()), true);
        sa.addField("Status", meetupDetails.getStatus(), true);
    }

    if (meetupDetails.getVenue() != null) {
        sa.addField("Venue", meetupDetails.getVenue().getName(), true);
    }

    LocalDateTime meetTime = meetupDetails.getMeetupTime();
    if (!IS_GMT) {
        // Correct for BST
        meetTime = meetTime.plusHours(1);
    }
    sa.addField("Date", meetTime.format(DT_FORMAT), true);

    if (meetupDetails.getHowToFindUs() != null && detailed) {
        sa.addField("How to find us", meetupDetails.getHowToFindUs(), false);
    }
    return sa;
}

From source file:de.elbe5.base.util.StringUtil.java

public static String toHtmlDate(LocalDateTime date, Locale locale) {
    if (date == null)
        return "";
    if (locale == null)
        locale = Locales.getInstance().getDefaultLocale();
    return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd", locale));
}

From source file:de.elbe5.base.util.StringUtil.java

public static String toHtmlTime(LocalDateTime date, Locale locale) {
    if (date == null)
        return "";
    if (locale == null)
        locale = Locales.getInstance().getDefaultLocale();
    return date.format(DateTimeFormatter.ofPattern("HH:mm:ss", locale));
}

From source file:de.elbe5.base.util.StringUtil.java

public static String toHtmlDateTime(LocalDateTime date, Locale locale) {
    if (date == null)
        return "";
    if (locale == null)
        locale = Locales.getInstance().getDefaultLocale();
    return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss", locale));
}