Example usage for org.joda.time LocalDateTime withYear

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

Introduction

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

Prototype

public LocalDateTime withYear(int year) 

Source Link

Document

Returns a copy of this datetime with the year field updated.

Usage

From source file:com.axelor.csv.script.ImportDateTime.java

License:Open Source License

public LocalDateTime updateYear(LocalDateTime dateTime, String year) {
    if (!Strings.isNullOrEmpty(year)) {
        Matcher matcher = patternYear.matcher(year);
        if (matcher.find()) {
            Integer years = Integer.parseInt(matcher.group());
            if (year.startsWith("+"))
                dateTime = dateTime.plusYears(years);
            else if (year.startsWith("-"))
                dateTime = dateTime.minusYears(years);
            else/*from  www .  jav  a 2s  . co m*/
                dateTime = dateTime.withYear(years);
        }
    }
    return dateTime;
}