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

com.github.yingzhuo.carnival.feign.converter.CalendarToStringConverter Maven / Gradle / Ivy

There is a newer version: 1.6.15
Show newest version
/*
 *  ____    _    ____  _   _ _____     ___    _
 * / ___|  / \  |  _ \| \ | |_ _\ \   / / \  | |
 * | |    / _ \ | |_) |  \| || | \ \ / / _ \ | |
 * | |___/ ___ \|  _ <| |\  || |  \ V / ___ \| |___
 * \____/_/   \_\_| \_\_| \_|___|  \_/_/   \_\_____|
 *
 * https://github.com/yingzhuo/carnival
 */
package com.github.yingzhuo.carnival.feign.converter;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.core.convert.converter.Converter;

import java.util.Calendar;
import java.util.Objects;

/**
 * @author 应卓
 * @since 1.6.0
 */
public class CalendarToStringConverter implements Converter {

    private final String pattern;

    public CalendarToStringConverter(String pattern) {
        this.pattern = Objects.requireNonNull(pattern);
    }

    @Override
    public String convert(Calendar calendar) {
        return DateFormatUtils.format(calendar, pattern);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy