package com.apobates.forum.thrones.tag;

import java.io.IOException;
import java.time.LocalDateTime;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import com.apobates.forum.utils.DateTimeUtils;
import java.util.Optional;

/**
 * RFC3339格式化日期
 *
 * @author xiaofanku
 * @since 20190714
 */
public class FormatLocalDateTimeTag extends SimpleTagSupport {
    private LocalDateTime value;
    
    @Override
    public void doTag() throws JspException, IOException {
        String sb = Optional.ofNullable(value).map(DateTimeUtils::getRFC3339).orElse("-");
        getJspContext().getOut().print(sb);
    }
    
    public void setValue(LocalDateTime value) {
        this.value = value;
    }
}