京东6.18大促主会场领京享红包更优惠

 找回密码
 立即注册

QQ登录

只需一步,快速开始

Java:日期字符串格式大小比较

2020-8-13 14:30| 发布者: zhaojun917| 查看: 4291| 评论: 0

摘要: 比较两个日期的大小,字符串格式的public class Timetest { public static void main(String args) { // TODO Auto-generated method stub String str1="2015-02-08 20:20:20"; String str2="2015-01-08 10:10:10"; ...

比较两个日期的大小,字符串格式的

public class Timetest {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String str1="2015-02-08 20:20:20";
        String str2="2015-01-08 10:10:10";
        int res=str1.compareTo(str2);
        if(res>0)
            System.out.println("str1>str2");
        else if(res==0)
            System.out.println("str1=str2");
        else
            System.out.println("str1<str2");
        }
}
关闭

站长推荐上一条 /6 下一条

QQ|手机版|小黑屋|梦想之都-俊月星空 ( 粤ICP备18056059号 )|网站地图

GMT+8, 2025-7-1 18:34 , Processed in 0.048797 second(s), 18 queries .

Powered by Mxzdjyxk! X3.5

© 2001-2025 Discuz! Team.

返回顶部