首页 > 编程知识 正文

java时间比较大小,java 日期转字符串

时间:2023-05-06 17:54:13 阅读:51572 作者:1227

字符串迁移日期时间//字符串迁移时间、formatType变换格式yyyy-mm-ddhh : mm : ss//yyyy年mm月DD日//HH时mm分ss秒/strTime的时间格式, 必须与formatType时间格式相同的publicstaticdatestringtodate (string strtime ) simpledateformatformatter=newsimpledateformat ) try { date=formatter.parse (strtime ); }catch(parseexceptione ) {e.printStackTrace ); }返回日期; }日期和时间字符串publicstaticstringdatetostring (datedate ) ) simpledateformatsdf=newsimpledateformat (yyyy-mm-DD ); string datestr=SDF.format (数据; 返回数据; }时间比较尺寸方法1 :

//1大、-1小、0相等if (date util.string todate (开始时间).com Pareto (date util.string todate ) )=1) cussime return }方法2 :

publicstaticbooleancomparetime (date begin time,Date endTime ) if (begin time.gettime ) (endTime.getTime ) )返回}返回}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。