約 3,270 件の結果
リンクを新しいタブで開く
  1. Java provides multiple ways to work with dates and times, primarily through the java.time API (introduced in Java 8) and the older java.util.Date class. The modern API is preferred for new development due to better design, immutability, and thread-safety.

    Modern Date/Time API (java.time package)

    • LocalDate – Represents a date without time (YYYY-MM-DD).

    • LocalTime – Represents a time without date (HH:MM:SS).

    • LocalDateTime – Represents both date and time.

    • DateTimeFormatter – Formats and parses date-time objects.

    Example:

    import java.time.LocalDate;
    import java.time.LocalDateTime;
    import java.time.format.DateTimeFormatter;

    public class Main {
    public static void main(String[] args) {
    LocalDate date = LocalDate.now();
    System.out.println("Current Date: " + date);

    LocalDateTime dateTime = LocalDateTime.now();
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
    System.out.println("Formatted DateTime: " + dateTime.format(formatter));
    }
    }
    コピーしました。
    フィードバック
    ありがとうございました!詳細をお聞かせください
  2. JavaのDateクラスの使い方を完全ガイド!初心者でもわかる日付操作

    2025年9月4日 · 1. java.util.Date クラスとは? 1. java.util.Date クラスとは? Date クラスは、Javaで「日付」と「時刻」をまとめて扱うための基本的なクラスです。 java.util パッケージに含まれていて …

  3. Java Date and Time - W3Schools

    Java does not have a built-in Date class, but we can import the java.time package to work with the date and time API. The package includes many date and time classes.

  4. Java – Dateクラスの使い方 – 基本的な日付処理

    2025年4月15日 · Dateクラスとは Javaの Dateクラス は、日付と時刻を表現するためのクラスです。 このクラスは、特定の瞬間をミリ秒単位で表現し、日付や時間の操作を行うためのメソッドを提供し …

  5. JavaのDateとは?日付・時刻APIの基本と正しい使い分け

    2 日前 · Dateクラスの概要と役割 まず、DateクラスはJava初期から存在する日付・時刻クラスです。 内部的には1970年1月1日を基準としたミリ秒を保持し、時刻情報を表現します。 そのため、単純 …

  6. JavaのDateとは?特定タイミングの日時を表現するクラス「Date」を …

    2025年10月6日 · この記事では、Javaで日時を表すDateについて、初心者向けに説明します。 Dateを扱う上で必要な考え方や使い方、実務でDateを使うならぜひ押さえておきたいプログラミング上のノ …

  7. 他の人も質問しています
  8. Date class in Java (With Examples) - GeeksforGeeks

    2019年1月2日 · The class Date represents a specific instant in time, with millisecond precision. The Date class of java.util package implements Serializable, Cloneable and Comparable interface.

  9. Java Date and Calendar: From Legacy to Modern Approaches

    2024年11月1日 · It was designed to solve many problems with the older Date and Calendar classes, making date and time manipulation more intuitive and user-friendly. Inspired by the popular Joda …

  10. Mastering the Java Date Class: A Comprehensive Guide

    In the world of Java programming, dealing with dates and times is a common requirement in various applications. Whether it's for scheduling tasks, calculating durations, or displaying timestamps, the …

  11. JavaのDateクラスとcompareToメソッドを完全解説!初心者向けjava.…

    2026年1月11日 · 1. java.utilパッケージとDateクラスとは? 1. java.utilパッケージとDateクラスとは? Javaの java.util パッケージには、日付や時間、リストやマップ、ランダムなどの便利なユーティリ …