Skip to content

Commit 5aef66e

Browse files
committed
~ edits
1 parent 0f9d3b0 commit 5aef66e

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,30 @@ val datetimeInSystemZone: LocalDateTime = currentMoment.toLocalDateTime(TimeZone
4848
```
4949

5050
`LocalDateTime` instance exposes familiar components of the Gregorian calendar:
51-
`year`, `month`, `dayOfMonth`, `hour`, and so on up to `nanosecond`.
51+
`year`, `month`, `dayOfMonth`, `hour`, and so on up to `nanosecond`.
52+
The property `dayOfWeek` shows what weekday that date is,
53+
and `dayOfYear` shows the day number since the beginning of a year.
54+
5255

5356
Additional time zones can be acquired by their string identifier with the `TimeZone.of(id: String)` function.
5457
```kotlin
5558
val tzBerlin = TimeZone.of("Europe/Berlin")
5659
val datetimeInBerlin = currentMoment.toLocalDateTime(tzBerlin)
5760
```
5861

62+
`LocalDateTime` instance can be constructed from individual components:
63+
64+
```kotlin
65+
val kotlinReleaseDateTime = LocalDateTime(2016, 2, 15, 16, 57, 0, 0)
66+
```
67+
68+
An instant can be obtained from `LocalDateTime` by interpreting it as a time moment
69+
in a particular `TimeZone`:
70+
71+
```kotlin
72+
val kotlinReleaseInstant = kotlinReleaseDateTime.toInstant(TimeZone.of("UTC+3"))
73+
```
74+
5975
### Getting local date components
6076

6177
`LocalDate` type represents local date without time. You can obtain it from `Instant`
@@ -67,6 +83,11 @@ val today: LocalDate = now.toLocalDateTime(TimeZone.SYSTEM).date
6783
```
6884
Note, that today's date really depends on the time zone in which you're observing the current moment.
6985

86+
`LocalDate` can be constructed from three components, year, month, and day:
87+
```kotlin
88+
val knownDate = LocalDate(2020, 2, 21)
89+
```
90+
7091
### Converting instant to and from unix time
7192

7293
An `Instant` can be converted to unix millisecond time with the `toUnixMillis()` function.
@@ -88,17 +109,16 @@ val instantBefore = Instant.parse("2010-06-01T22:19:44.475Z")
88109
Alternatively, `String.to...()` extension functions can be used instead of `parse`,
89110
where it feels more convenient:
90111

112+
`LocalDateTime` uses the similar format, but without `Z` UTC time zone designator in the end.
113+
114+
`LocalDate` uses format with just year, month, and date components, e.g. `2010-06-01`.
115+
91116
```kotlin
92117
"2010-06-01T22:19:44.475Z".toInstant()
93118
"2010-06-01T22:19:44".toLocalDateTime()
94119
"2010-06-01".toLocalDate()
95120
```
96121

97-
`LocalDateTime` uses the similar format, but without `Z` UTC time zone designator in the end.
98-
99-
`LocalDate` uses format with just year, month, and date components, e.g. `2010-06-01`.
100-
101-
102122
### Instant arithmetic
103123

104124
```kotlin
@@ -166,4 +186,8 @@ git submodule init
166186
git submodule update
167187
```
168188

189+
The path to JDK 8 must be specified either with the environment variable `JDK_8` or
190+
with the gradle property `JDK_8`. For local builds, you can use a later version of JDK if you don't have that
191+
version installed.
192+
169193
After that, the project can be opened in IDEA and built with Gradle.

0 commit comments

Comments
 (0)