0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ライブラリ

Posted at

ライブラリ

よく利用される機能を切り出して、再利用しやすいようにまとめたもの。ライブラリの利用により、機能を1から作る必要がなくなり、効率的に開発を行うことができる。
一般的に、Javaのライブラリは「JARファイル(.jar)」で提供される。
jarファイルは、コンパイル時に生成される複数の「classファイル」をまとめたもの。

使い方

利用時には、ライブラリ内の汎用的なクラスを呼び出すだけで、そのクラス機能を利用することができる。
日付を扱うことができるクラスライブラリCalendarを使ってみる。
使う時はimportする。

import java.util.Calendar; //クラスをimport

public class Main {
    public static void main(String[] args) throws Exception {       
      Calendar now = Calendar.getInstance() ;
      
      int year = now.get(Calendar.YEAR);
      int month = now.get(Calendar.MONTH);
      int date = now.get(Calendar.DATE);
      int hour = now.get(Calendar.HOUR);
      int minute = now.get(Calendar.MINUTE);
      int second = now.get(Calendar.SECOND);
      
      System.out.print(year + "年");
      System.out.print(month + "月");
      System.out.print(date + "日");
      System.out.print(hour + "時");
      System.out.print(minute + "分");
      System.out.println(second + "秒");
    }
}

結果

2023年6月15日23時09分50秒
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?