Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d6194a2b9 | ||
|
|
3f3c33b29c | ||
|
|
03924959e3 | ||
|
|
6f86edffd1 | ||
|
|
71e199f419 | ||
|
|
7e797f23b6 | ||
|
|
92447c1a5b | ||
|
|
7140dc71e4 | ||
|
|
350cb41b00 | ||
|
|
a17a5ef5b5 |
Generated
+2
-1
@@ -7,7 +7,6 @@
|
|||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="jackson-annotations" />
|
|
||||||
<module name="assertion-libraries" />
|
<module name="assertion-libraries" />
|
||||||
<module name="core-java-serialization" />
|
<module name="core-java-serialization" />
|
||||||
<module name="core-java-annotations" />
|
<module name="core-java-annotations" />
|
||||||
@@ -33,6 +32,7 @@
|
|||||||
<module name="core-java-streams" />
|
<module name="core-java-streams" />
|
||||||
<module name="core-java-io-2" />
|
<module name="core-java-io-2" />
|
||||||
<module name="core-java-io" />
|
<module name="core-java-io" />
|
||||||
|
<module name="core-java-8-datetime" />
|
||||||
<module name="discourse" />
|
<module name="discourse" />
|
||||||
<module name="image-processing" />
|
<module name="image-processing" />
|
||||||
<module name="jackson-jr" />
|
<module name="jackson-jr" />
|
||||||
@@ -55,6 +55,7 @@
|
|||||||
<module name="core-java-11-2" target="11" />
|
<module name="core-java-11-2" target="11" />
|
||||||
<module name="core-java-8-2" target="11" />
|
<module name="core-java-8-2" target="11" />
|
||||||
<module name="core-java-collections-list-3" target="11" />
|
<module name="core-java-collections-list-3" target="11" />
|
||||||
|
<module name="jackson-annotations" target="17" />
|
||||||
<module name="spring-data-jpa-repo-2" target="17" />
|
<module name="spring-data-jpa-repo-2" target="17" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
Generated
+2
@@ -15,6 +15,8 @@
|
|||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-11/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-11/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8-2/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8-2/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8-2/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8-2/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8-datetime/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8-datetime/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-8/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-9/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-9/src/main/java" charset="UTF-8" />
|
||||||
|
|||||||
-1
@@ -1,7 +1,6 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 iSharkFly
|
Copyright (c) 2024 iSharkFly
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ Java 代码使用的是 JDK 17。
|
|||||||
|
|
||||||
请使用下面的联系方式和我们联系:
|
请使用下面的联系方式和我们联系:
|
||||||
|
|
||||||
| 联系方式名称 | 联系方式 |
|
| 联系方式名称 | 联系方式 |
|
||||||
|--------|------------------------------------------------------|
|
|--------|-----------------------------------------------|
|
||||||
| 电子邮件 | [[email protected]](mailto:[email protected]) |
|
| 电子邮件 | [[email protected]](mailto:[email protected]) |
|
||||||
| QQ 或微信 | 103899765 |
|
| QQ 或微信 | 103899765 |
|
||||||
| QQ 交流群 | 15186112 |
|
| QQ 交流群 | 15186112 |
|
||||||
| 社区论坛 | https://www.isharkfly.com/c/computer-program/java/15 |
|
| 社区论坛 | https://www.ossez.com/c/open-source/java/15 |
|
||||||
|
|
||||||
# 公众平台
|
# 公众平台
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
## Java 8+ Date and Time API
|
## Java 8+ Date 和 Time API
|
||||||
|
|
||||||
This module contains articles about the Date and Time API introduced with Java 8.
|
本模块中包含的内容有关 Java 8 中使用日期和时间的 API。
|
||||||
|
|
||||||
### Relevant Articles:
|
### 相关文章:
|
||||||
- [Introduction to the Java 8 Date/Time API](http://www.baeldung.com/java-8-date-time-intro)
|
- [Introduction to the Java 8 Date/Time API](http://www.baeldung.com/java-8-date-time-intro)
|
||||||
- [Migrating to the New Java 8 Date Time API](http://www.baeldung.com/migrating-to-java-8-date-time-api)
|
- [Migrating to the New Java 8 Date Time API](http://www.baeldung.com/migrating-to-java-8-date-time-api)
|
||||||
- [Get the Current Date and Time in Java](https://www.baeldung.com/current-date-time-and-timestamp-in-java-8)
|
- [Get the Current Date and Time in Java](https://www.baeldung.com/current-date-time-and-timestamp-in-java-8)
|
||||||
- [TemporalAdjuster in Java](http://www.baeldung.com/java-temporal-adjuster)
|
- [TemporalAdjuster in Java](http://www.baeldung.com/java-temporal-adjuster)
|
||||||
- [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset)
|
- [Java 中的 ZoneOffset](https://www.isharkfly.com/t/java-zoneoffset/16803)
|
||||||
- [Differences Between ZonedDateTime and OffsetDateTime](https://www.baeldung.com/java-zoneddatetime-offsetdatetime)
|
- [Differences Between ZonedDateTime and OffsetDateTime](https://www.baeldung.com/java-zoneddatetime-offsetdatetime)
|
||||||
- [Period and Duration in Java](http://www.baeldung.com/java-period-duration)
|
- [Java 中的 Period 和 Duration](https://www.isharkfly.com/t/java-period-duration/16809)
|
||||||
- [How to Get the Start and the End of a Day using Java](http://www.baeldung.com/java-day-start-end)
|
- [How to Get the Start and the End of a Day using Java](http://www.baeldung.com/java-day-start-end)
|
||||||
- [Set the Time Zone of a Date in Java](https://www.baeldung.com/java-set-date-time-zone)
|
- [Set the Time Zone of a Date in Java](https://www.baeldung.com/java-set-date-time-zone)
|
||||||
- [Comparing Dates in Java](https://www.baeldung.com/java-comparing-dates)
|
- [Comparing Dates in Java](https://www.baeldung.com/java-comparing-dates)
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
<name>core-java-8-datetime</name>
|
<name>core-java-8-datetime</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung.core-java-modules</groupId>
|
<groupId>com.ossez.core-java-modules</groupId>
|
||||||
<artifactId>core-java-modules</artifactId>
|
<artifactId>core-java-modules</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.2-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.date.comparison;
|
package com.ossez.date.comparison;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.date.comparison;
|
package com.ossez.date.comparison;
|
||||||
|
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ossez.datetime;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class CalendarUtils {
|
||||||
|
public static Calendar getPlusDays(Date date, int amount) throws ParseException {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.DAY_OF_YEAR, amount);
|
||||||
|
return calendar;
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.ossez.datetime;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
public class DateUtils {
|
||||||
|
|
||||||
|
public static Date getNow() {
|
||||||
|
return new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date getDate(long millis) {
|
||||||
|
return new Date(millis);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date getDate(String dateAsString, String pattern) throws ParseException {
|
||||||
|
return new SimpleDateFormat(pattern).parse(dateAsString);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.Period;
|
import java.time.Period;
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ossez.datetime;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
public class UseSimpleDateFormat {
|
||||||
|
|
||||||
|
public String useFormat() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata"));
|
||||||
|
Date date = new Date(1725437542000L);
|
||||||
|
return sdf.format(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.datetime;
|
package com.ossez.datetime;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ossez.datetime.sql;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
public class DateUtils {
|
||||||
|
|
||||||
|
public static Date getNow() {
|
||||||
|
return new Date(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date getDate(String dateAsString) {
|
||||||
|
return Date.valueOf(dateAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date getDate(String dateAsString, String pattern) throws ParseException {
|
||||||
|
java.util.Date customUtilDate = new SimpleDateFormat(pattern).parse(dateAsString);
|
||||||
|
return new Date(customUtilDate.getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ossez.datetime.sql;
|
||||||
|
|
||||||
|
import java.sql.Time;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
public class TimeUtils {
|
||||||
|
|
||||||
|
public static Time getNow() {
|
||||||
|
return new Time(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Time getTime(String timeAsString) {
|
||||||
|
return Time.valueOf(timeAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Time getTime(String dateAsString, String pattern) throws ParseException {
|
||||||
|
java.util.Date customUtilDate = new SimpleDateFormat(pattern).parse(dateAsString);
|
||||||
|
return new Time(customUtilDate.getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ossez.datetime.sql;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
public class TimestampUtils {
|
||||||
|
|
||||||
|
public static Timestamp getNow() {
|
||||||
|
return new Timestamp(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timestamp getTimestamp(String timestampAsString) {
|
||||||
|
return Timestamp.valueOf(timestampAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timestamp getTimestamp(String dateAsString, String pattern) throws ParseException {
|
||||||
|
java.util.Date customUtilDate = new SimpleDateFormat(pattern).parse(dateAsString);
|
||||||
|
return new Timestamp(customUtilDate.getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.temporaladjuster;
|
package com.ossez.temporaladjuster;
|
||||||
|
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.temporal.ChronoField;
|
import java.time.temporal.ChronoField;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.date.comparison;
|
package com.ossez.date.comparison;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.date.comparison;
|
package com.ossez.date.comparison;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.date.comparison;
|
package com.ossez.date.comparison;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.dateapi;
|
package com.ossez.dateapi;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.baeldung.dateapi;
|
package com.ossez.dateapi;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user