📄 showtimewithoutna.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 + -