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

com.iqiny.silly.spring.spel.field.SillyFormatDateValuesField Maven / Gradle / Ivy

/*
 *  Copyright  iqiny.com
 *
 *  https://gitee.com/iqiny/silly
 *
 *  project name:silly-spring
 *  project description:top silly project pom.xml file
 */
package com.iqiny.silly.spring.spel.field;

import com.iqiny.silly.common.util.SillyDateUtils;
import com.iqiny.silly.core.config.property.valuesfield.BaseSillyMethodPropertyValuesField;
import com.iqiny.silly.core.savehandle.SillyOnceSourceData;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 格式化 Date
 */
@Component
public class SillyFormatDateValuesField extends BaseSillyMethodPropertyValuesField {

    public static final String NAME = "formatDate";

    @Override
    public String fieldName() {
        return NAME;
    }

    @Override
    protected Class[] getParameterTypes(SillyOnceSourceData data) {
        return new Class[]{Date.class, String.class};
    }

    public static String formatDate(Date date, String pattern) {
        if (date == null) {
            return null;
        }

        return SillyDateUtils.formatDate(date, pattern);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy