欢迎光临
我们一直在努力

如何判断输入的文本是否日期格式-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

try{    date.valueof(string astring);}catch(exception ex){    system.err.println("the format of string is not correct");}

或者

public class forother {    public static void main(string[] args){                simpledateformat s=new simpledateformat("yyyy-mm-dd hh:mm:ss");               string ooo="2005-02-18 15:39:15";        string ppp="2005-02-01 15:25:15";              try{        date tt=s.parse(ooo);        date yy=s.parse(ppp);        long aa;        if(tt.gettime()>yy.gettime())            aa=tt.gettime()-yy.gettime();        else            aa=yy.gettime()-tt.gettime();        long date=aa/1000/60/60/24;        system.out.println("***");        system.out.println("hahahha"+date);        system.out.println("*******");        }catch(exception e){                    }           }}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何判断输入的文本是否日期格式-JSP教程,Java技巧及代码
分享到: 更多 (0)