Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
java.util.Date、java.util.Calendar、およびjava.text.SimpleDateFormatを使用して、2つの日付の間に経過した日数を計算する必要があります。私は脳を壊しています、どうすればそれを達成できますか?
インタビューの質問のようですが、2 か月前のインタビューでも同様の質問がありました。
さて、ここにもう 1 つのヒントがあります。あなたには 2 つの日付があります。Java は、日付ごとに時間をミリ単位で提供します。t1 と t2 とします。
一般性を失うことなく、t1>t2 と仮定できます。今t = t1-t2
t を 86400 * 1000 (1 日のミリ秒数) で割り、それが答えです:)