10 Commits
82 changed files with 315 additions and 1959 deletions
+2 -1
View File
@@ -7,7 +7,6 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="jackson-annotations" />
<module name="assertion-libraries" />
<module name="core-java-serialization" />
<module name="core-java-annotations" />
@@ -33,6 +32,7 @@
<module name="core-java-streams" />
<module name="core-java-io-2" />
<module name="core-java-io" />
<module name="core-java-8-datetime" />
<module name="discourse" />
<module name="image-processing" />
<module name="jackson-jr" />
@@ -55,6 +55,7 @@
<module name="core-java-11-2" target="11" />
<module name="core-java-8-2" 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" />
</bytecodeTargetLevel>
</component>
+2
View File
@@ -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-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-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/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/core-java-modules/core-java-9/src/main/java" charset="UTF-8" />
-1
View File
@@ -1,7 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<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" />
</profile>
</component>
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2025 iSharkFly
Copyright (c) 2024 iSharkFly
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+6 -6
View File
@@ -15,12 +15,12 @@ Java 代码使用的是 JDK 17。
请使用下面的联系方式和我们联系:
| 联系方式名称 | 联系方式 |
|--------|------------------------------------------------------|
| 电子邮件 | [[email protected]](mailto:[email protected]) |
| QQ 或微信 | 103899765 |
| QQ 交流群 | 15186112 |
| 社区论坛 | https://www.isharkfly.com/c/computer-program/java/15 |
| 联系方式名称 | 联系方式 |
|--------|-----------------------------------------------|
| 电子邮件 | [[email protected]](mailto:[email protected]) |
| QQ 或微信 | 103899765 |
| QQ 交流群 | 15186112 |
| 社区论坛 | 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)
- [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)
- [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)
- [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)
- [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)
@@ -8,9 +8,9 @@
<name>core-java-8-datetime</name>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
<groupId>com.ossez.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</parent>
<dependencies>
@@ -1,4 +1,4 @@
package com.baeldung.date.comparison;
package com.ossez.date.comparison;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -1,4 +1,4 @@
package com.baeldung.date.comparison;
package com.ossez.date.comparison;
import org.apache.commons.lang3.time.DateUtils;
@@ -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;
}
}
@@ -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,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.Duration;
import java.time.LocalTime;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.DayOfWeek;
import java.time.LocalDate;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalDate;
import java.time.Period;
@@ -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,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -1,4 +1,4 @@
package com.baeldung.datetime;
package com.ossez.datetime;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -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());
}
}
@@ -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());
}
}
@@ -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,4 +1,4 @@
package com.baeldung.temporaladjuster;
package com.ossez.temporaladjuster;
import java.time.DayOfWeek;
import java.time.temporal.ChronoField;
@@ -1,4 +1,4 @@
package com.baeldung.date.comparison;
package com.ossez.date.comparison;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -1,4 +1,4 @@
package com.baeldung.dateapi;
package com.ossez.dateapi;
import java.time.Instant;
import java.time.ZoneId;
@@ -1,4 +1,4 @@
package com.baeldung.dateapi;
package com.ossez.dateapi;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;

Some files were not shown because too many files have changed in this diff Show More