[JAVA] Usability of date and time classes in each language

Is there a difference in the usability of the date and time classes in each language? There was a topic called, and I tried to move it roughly, so I made a note. My feeling is that the date and time class is basically a recognition that represents a certain time (point). (Recognized that when initialized at '2020 / 8/21 23:59', it does not refer to the entire 59 minutes, but roughly indicates 0 seconds)

Ruby

# https://docs.ruby-lang.org/ja/latest/class/Time.html

st_t = Time.new(2020,8,21,23,59)
p st_t

check_t = Time.new(2020,8,21,23,59,30)
p (st_t < check_t)
2020-08-21 23:59:00 +0900
true

JavaScript

/*
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date
*/
//Month is 0 base point
const st_t = new Date(2020, 8-1, 21, 23, 59);
console.log(st_t.toLocaleString("ja"));

const check_t = new Date(2020, 8-1, 21, 23, 59, 30);
console.log(
2020/8/21 23:59:00
true

PHP

<?php

# https://www.php.net/manual/ja/class.datetime.php

$st_t = new DateTime('2020-08-21T23:59');
echo $st_t->format('Y-m-d H:i:s.u');
echo "\n";

$check_t = new DateTime('2020-08-21T23:59:30');
echo $check_t->format('Y-m-d H:i:s.u');
echo "\n";


$res = ($st_t < $check_t);
if ($res){
  echo "true";
}
else{
  echo "false";
}
echo "\n";

2020-08-21 23:59:00.000000
2020-08-21 23:59:30.000000
true

All as expected.

Recommended Posts

Usability of date and time classes in each language
Handling of date and time in Ruby. Use Date and Time properly.
Explanation of Ruby Time and Date objects
Change date and time to Japanese notation in Rails
[For beginners] Explanation of classes, instances, and statics in Java
Handling of invalid dates (such as February 31) in each language
[Rails] Search method when date and time have each column
Get the current date and time by specifying the time zone in Thymeleaf
The design concept of Java's Date and Time API is interesting
[MySQL] [java] Receive date and time
[Java] for Each and sorted in Lambda
Summary of root classes in various languages
Summary of hashes and symbols in Ruby
[Ruby] Classification and usage of loops in Ruby
Comparison of JavaScript objects and Ruby classes
Discrimination of Enums in Java 7 and above
Parse the date and time string formatted by the C asctime function in Java
Format the date and time given by created_at
About the idea of anonymous classes in Java
About date / time type of Doma2 entity class
[Java] Personal summary of classes and methods (basic)
Feel the passage of time even in Java
Differences in writing Java, C # and Javascript classes
Date and time acquisition method using DateAndTime API
Basics of threads and Callable in Java [Beginner]
The date time of java8 has been updated
Summary of Japan time setting and display method
Toward understanding of map and flatmap in Stream (1)
[Rails] Ranking and pagination in order of likes