Javatime-localdatetime

提供:Dev Guides
移動先:案内検索

java.time.LocalDateTimeクラス

前書き

*java.time.LocalDateTime* クラスは、ISO-8601カレンダーシステムのタイムゾーンのない日時(2007-12-03T10:15:30など)を表します。

クラス宣言

以下は java.time.LocalDateTime クラスの宣言です-

public final class LocalDateTime
   extends Object
      implements Temporal, TemporalAdjuster, ChronoLocalDateTime, Serializable

フィールド

以下は java.time.LocalDateTime クラスのフィールドです-

  • static LocalDateTime MAX -サポートされるLocalDateTimeの最大値「+ 999999999-12-31T23:59:59.999999999」。
  • static LocalDateTime MIN -サポートされる最小のLocalDateTime、「-999999999-01-01T00:00:00」。

クラスメソッド

Sr.No. Method & Description
1

Temporal adjustInto(Temporal temporal)

指定された一時オブジェクトを調整して、このオブジェクトと同じ日時を持ちます。

2

OffsetDateTime atOffset(ZoneOffset offset)

この日時をオフセット時間と組み合わせて、OffsetDateTimeを作成します。

3

ZonedDateTime atZone(ZoneId zone)

この日時をタイムゾーンと組み合わせて、ZonedDateTimeを作成します。

4

int compareTo(ChronoLocalDateTime<?> other)

この日時を別の日時と比較します。

5

boolean equals(Object obj)

この日時が別の日時と等しいかどうかを確認します。

6

String format(DateTimeFormatter formatter)

指定されたフォーマッタを使用してこの日時をフォーマットします。

7

static LocalDateTime from(TemporalAccessor temporal)

一時オブジェクトからLocalDateTimeのインスタンスを取得します。

8

int get(TemporalField field)

この日時から指定されたフィールドの値をintとして取得します。

9

int getDayOfMonth()

月の日フィールドを取得します。

10

DayOfWeek getDayOfWeek()

曜日フィールドを取得します。これは列挙型DayOfWeekです。

11

int getDayOfYear()

年間通算日フィールドを取得します。

12

int getHour()

時間帯フィールドを取得します。

13

long getLong(TemporalField field)

この日時から指定されたフィールドの値をlongとして取得します。

14

Month getMinute()

分単位のフィールドを取得します。

15

Month getMonth()

Month列挙を使用して、月のフィールドを取得します。

16

int getMonthValue()

1〜12の月のフィールドを取得します。

17

int getNano()

秒単位のフィールドを取得します。

18

int getSecond()

秒のフィールドを取得します。

19

int getYear()

年フィールドを取得します。

20

int hashCode()

この日時のハッシュコード。

21

boolean isAfter(ChronoLocalDateTime<?> other)

この日時が指定された日時より後かどうかを確認します。

22

boolean isBefore(ChronoLocalDateTime<?> other)

この日時が指定された日時より前かどうかを確認します。

23

boolean isEqual(ChronoLocalDateTime<?> other)

この日時が指定された日時と等しいかどうかを確認します。

24

boolean isSupported(TemporalField field)

指定されたフィールドがサポートされているかどうかを確認します。

25

boolean isSupported(TemporalUnit unit)

指定されたユニットがサポートされているかどうかを確認します。

26

LocalDateTime minus(long amountToSubtract, TemporalUnit unit)

指定された量を差し引いたこの日時のコピーを返します。

27

LocalDateTime minus(TemporalAmount amountToSubtract)

指定された量を差し引いたこの日時のコピーを返します。

28

LocalDateTime minusDays(long daysToSubtract)

指定された日数を引いたこのLocalDateTimeのコピーを返します。

29

LocalDateTime minusHours(long hoursToSubtract)

指定された時間数を減算した、このLocalDateTimeのコピーを返します。

30

LocalDateTime minusMinutes(long minutesToSubtract)

指定された分数を差し引いたこのLocalDateTimeのコピーを返します。

31

LocalDateTime minusMonths(long monthsToSubtract)

指定された月数を減算した、このLocalDateTimeのコピーを返します。

32

LocalDateTime minusNanos(long nanos)

指定されたナノ秒数を減算した、このLocalDateTimeのコピーを返します。

33

LocalDateTime minusSeconds(long seconds)

指定された秒数を減算した、このLocalDateTimeのコピーを返します。

34

LocalDateTime minusWeeks(long weeksToSubtract)

指定された週数を差し引いたこのLocalDateTimeのコピーを返します。

35

LocalDateTime minusYears(long yearsToSubtract)

指定された年数を減算した、このLocalDateTimeのコピーを返します。

36

static LocalDateTime now()

デフォルトのタイムゾーンのシステムクロックから現在の日時を取得します。

37

static LocalDateTime now(Clock clock)

指定されたクロックから現在の日時を取得します。

38

static LocalDateTime now(ZoneId zone)

指定されたタイムゾーンのシステムクロックから現在の日時を取得します。

39

static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute)

年、月、日、時間、分からLocalDateTimeのインスタンスを取得し、秒とナノ秒をゼロに設定します。

40

static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second)

年、月、日、時間、分、秒からLocalDateTimeのインスタンスを取得し、ナノ秒をゼロに設定します。

41

static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)

年、月、日、時間、分、秒、ナノ秒からLocalDateTimeのインスタンスを取得します。

42

static LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second)

年、月、日、時間、分、秒からLocalDateTimeのインスタンスを取得し、ナノ秒をゼロに設定します。

43

static LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)

年、月、日、時間、分、秒、ナノ秒からLocalDateTimeのインスタンスを取得します。

44

static LocalDateTime of(LocalDate date, LocalTime time)

日付と時刻からLocalDateTimeのインスタンスを取得します。

45

static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset)

1970-01-01T00:00:00ZのエポックからLocalDateTimeのインスタンスを取得します。

46

static LocalDateTime ofInstant(Instant instant, ZoneId zone)

InstantおよびゾーンIDからLocalDateTimeのインスタンスを取得します。

47

static LocalDateTime parse(CharSequence text)

2007-12-03T10:15:30などのテキスト文字列からLocalDateTimeのインスタンスを取得します。

48

static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)

特定のフォーマッターを使用して、テキスト文字列からLocalDateTimeのインスタンスを取得します。

49

LocalDateTime plus(long amountToAdd, TemporalUnit unit)

指定された量が追加されたこの日時のコピーを返します。

50

LocalDateTime plus(TemporalAmount amountToAdd)

指定された量が追加されたこの日時のコピーを返します。

51

LocalDateTime plusDays(long daysToAdd)

指定された日数が追加されたこのLocalDateTimeのコピーを返します。

52

LocalDateTime plusHours(long hoursToAdd)

指定された時間数を加算したこのLocalDateTimeのコピーを返します。

53

LocalDateTime plusMinutes(long minutesToAdd)

指定された分数を加算したこのLocalDateTimeのコピーを返します。

54

LocalDateTime plusMonths(long monthsToAdd)

指定された月数が追加されたこのLocalDateTimeのコピーを返します。

55

LocalDateTime plusNanos(long nanos)

指定されたナノ秒数が追加されたこのLocalDateTimeのコピーを返します。

56

LocalDateTime plusSeconds(long seconds)

指定された秒数を加算したこのLocalDateTimeのコピーを返します。

57

LocalDateTime plusWeeks(long weeksToAdd)

指定された週数が追加されたこのLocalDateTimeのコピーを返します。

58

LocalDateTime plusYears(long yearsToAdd)

指定された年数が追加されたこのLocalDateTimeのコピーを返します。

59

<R> R query(TemporalQuery<R> query)

指定されたクエリを使用してこの日時をクエリします。

60

ValueRange range(TemporalField field)

指定されたフィールドの有効な値の範囲を取得します。

61

LocalDate toLocalDate()

この日時のLocalDate部分を取得します。

62

LocalTime toLocalTime()

この日時のLocalTime部分を取得します。

63

String toString()

この日付を2007-12-03T10:15:30などの文字列として出力します。

64

LocalDateTime truncatedTo(TemporalUnit unit)

時刻が切り捨てられたこのLocalDateTimeのコピーを返します。

65

long until(Temporal endExclusive, TemporalUnit unit)

指定された単位で、別の日時までの時間を計算します。

66

LocalDateTime with(TemporalAdjuster adjuster)

この日時の調整済みコピーを返します。

67

LocalDateTime with(TemporalField field, long newValue)

指定されたフィールドを新しい値に設定して、この日時のコピーを返します。

68

LocalDateTime withDayOfMonth(int dayOfMonth)

月の日付を変更して、このLocalDateTimeのコピーを返します。

69

LocalDateTime withDayOfYear(int dayOfYear)

年の日付を変更して、このLocalDateTimeのコピーを返します。

70

LocalDateTime withHour(int hour)

時刻を変更して、このLocalDateTimeのコピーを返します。

71

LocalDateTime withMinute(int minute)

分を変更して、このLocalDateTimeのコピーを返します。

72

LocalDateTime withMonth(int month)

年の月を変更して、このLocalDateTimeのコピーを返します。

73

LocalDateTime withNano(int nanoOfSecond)

ナノ秒を変更して、このLocalDateTimeのコピーを返します。

74

LocalDateTime withSecond(int second)

分を変更して、このLocalDateTimeのコピーを返します。

75

LocalDateTime withYear(int year)

年を変更して、このLocalDateTimeのコピーを返します。

継承されたメソッド

このクラスは、次のクラスからメソッドを継承します-

  • Java.lang.Object