gpt4 book ai didi

java - android Date 和 SimpleDateFormat 输出错误

转载 作者:行者123 更新时间:2023-12-01 12:22:54 25 4
gpt4 key购买 nike

我不知道为什么输入不同,但输出是重复的,这是我的代码

        Date d = new Date(1409716800);
Date d1 = new Date(1409716801);
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy-HH:mm:ss");
String formattedDate = sdf.format(d);
String formattedDate1 = sdf.format(d1);

Log.d("time", formattedDate);
Log.d("time", formattedDate1);

输出为

   10-24 06:12:50.508: D/time(29097): 17.01.70-07:35:16
10-24 06:12:50.508: D/time(29097): 17.01.70-07:35:16

谁能告诉我为什么输出是重复的?我的时区是 GMT+7

最佳答案

    Date d = new Date(1409716800);
Date d1 = new Date(1409716801);
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy-HH:mm:ss:SSS");
String formattedDate = sdf.format(d);
String formattedDate1 = sdf.format(d1);

Log.d("time", formattedDate);
Log.d("time", formattedDate1);

输出:

    17.01.70-14:35:16:800
17.01.70-14:35:16:801

关于java - android Date 和 SimpleDateFormat 输出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26542359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com