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

📄 showtimewithoutna.java

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JAVA
字号:
package cn.jsprun.taglib;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;


public class ShowTimeWithoutNA extends TagSupport {
	private static final long serialVersionUID = 7199857750621602453L;
	private Integer timeInt;
	private boolean isView = true;
	private boolean isShowDefault=false;
	private String type = null;
	
	public void setTimeInt(Integer timeInt){
		this.timeInt = timeInt;
	}
	public void setIsView(String isView){
		if(isView!=null && isView.equals("false")){
			this.isView = false;
		}else{
			this.isView = true;
		}
	}
	public void setIsShowDefault(String isShowDefault){
		if(isShowDefault!=null && isShowDefault.equals("true")){
			this.isShowDefault = true;
		}else{
			this.isShowDefault = false;
		}
	}
	public void setType(String type){
		if(type.equals("")){
			this.type = "yyyy-MM-dd";
		}else{
			this.type = type;
		}
	}
	@Override
	public int doStartTag() throws JspException {
		if(this.type==null){
			this.type = "yyyy-MM-dd";
		}
		long timeLong =timeInt*1000l;
		try {
			if(timeLong>0)
			{
				pageContext.getOut().write(new SimpleDateFormat(type).format(timeLong));
			}
			else{
				if(isShowDefault){
					pageContext.getOut().write(new SimpleDateFormat(type).format(new Date()));
				}else{
					if(isView){
						pageContext.getOut().write("无限制");
					}
				}
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return super.doStartTag();
	}
}

⌨️ 快捷键说明

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