Example usage for org.joda.time LocalDateTime fromDateFields

List of usage examples for org.joda.time LocalDateTime fromDateFields

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime fromDateFields.

Prototype

@SuppressWarnings("deprecation")
public static LocalDateTime fromDateFields(Date date) 

Source Link

Document

Constructs a LocalDateTime from a java.util.Date using exactly the same field values.

Usage

From source file:org.jtwig.functions.builtin.DateFunctions.java

License:Apache License

@JtwigFunction(name = "date")
public String format(@Parameter Date input, @Parameter String format) {
    if (input == null)
        return "";

    String jodaFormat = PHPDateFormatConverter.convertDateFormat(format);

    DateTimeFormatter formatter = DateTimeFormat.forPattern(jodaFormat);
    return LocalDateTime.fromDateFields(input).toString(formatter);
}

From source file:org.jtwig.functions.builtin.DateFunctions.java

License:Apache License

@JtwigFunction(name = "date")
public String format(@Parameter Date input) {
    if (input == null)
        return "";

    return LocalDateTime.fromDateFields(input).toString(ISODateTimeFormat.dateHourMinuteSecond());
}

From source file:org.vraptor.impl.converter.jodatime.LocalDateTimeConverter.java

License:Open Source License

public LocalDateTime convert(String value, Class<? extends LocalDateTime> type, ResourceBundle bundle) {
    try {// w w w.ja  va2  s.  co m
        Date datetime = new LocaleBasedJodaTimeConverter(localization.get()).convert(value, type);
        if (datetime == null) {
            return null;
        }
        return LocalDateTime.fromDateFields(datetime);
    } catch (Exception e) {
        throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value));
    }
}