All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.supwisdom.spreadsheet.mapper.o2w.converter.LocalDatePropertyStringifier Maven / Gradle / Ivy

There is a newer version: 1.0.9
Show newest version
package com.supwisdom.spreadsheet.mapper.o2w.converter;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * local date text value with supplied pattern converter
 * Created by hanwen on 5/3/16.
 */
public class LocalDatePropertyStringifier extends PropertyStringifierTemplate {

  private String pattern;

  public LocalDatePropertyStringifier(String pattern) {
    this.pattern = pattern;
  }

  @Override
  public String convertProperty(Object property) {

    if (!LocalDate.class.equals(property.getClass())) {
      throw new IllegalArgumentException(
          "Not a LocalDate: " + property.getClass().getName() + " value: " + property.toString());
    }

    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
    return ((LocalDate) property).format(dateTimeFormatter);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy