⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dateformatter.java

📁 HR系统模拟企业对内部职员的管理
💻 JAVA
字号:
package org.operamasks.example.ejb.hr.util;import java.text.SimpleDateFormat;import java.util.Date;import java.util.TimeZone;import javax.faces.context.FacesContext;import javax.faces.convert.DateTimeConverter;import org.operamasks.faces.annotation.Convert;import org.operamasks.faces.annotation.DefineConverter;import org.operamasks.faces.annotation.Format;import org.operamasks.faces.component.layout.UIFacelet;@DefineConverter(id="outputDateFormatter")public class DateFormatter {	@Format    public String format(Object value) {        if (value instanceof Date) {            SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getInstance();            formatter.applyPattern("yy-M-d");            formatter.setTimeZone(TimeZone.getTimeZone("GMT+8"));            return formatter.format(value);        }        return value == null ? "" : value.toString();    }        @Convert    public Object convert(String value) {        FacesContext context = FacesContext.getCurrentInstance();        DateTimeConverter converter = (DateTimeConverter)context.getApplication().createConverter(DateTimeConverter.CONVERTER_ID);        converter.setPattern("yyyy-MM-dd");        converter.setTimeZone(TimeZone.getTimeZone("GMT+8"));        return converter.getAsObject(context, new UIFacelet(), value);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -