添加注释

pull/1/head
ZhouXY108 2024-11-19 21:59:03 +08:00
parent 3f0c14f2d9
commit 8d24d8de23
1 changed files with 49 additions and 15 deletions

View File

@ -67,6 +67,8 @@ public class DateTimeTools {
return DATE_TIME_FORMATTER_CACHE.getUnchecked(pattern);
}
// #region - toString
/**
*
*
@ -103,6 +105,10 @@ public class DateTimeTools {
return toString(pattern, dateTime);
}
// #endregion
// #region - nowStr
/**
*
*
@ -124,7 +130,9 @@ public class DateTimeTools {
return toString(pattern, Instant.now().atZone(zone));
}
// toDate
// #endregion
// #region - toDate
/**
* {@link Date}
@ -189,7 +197,9 @@ public class DateTimeTools {
return Date.from(ZonedDateTime.of(localDate, localTime, zone).toInstant());
}
// toInstant
// #endregion
// #region - toInstant
/**
* {@link Instant}
@ -244,7 +254,9 @@ public class DateTimeTools {
return ZonedDateTime.of(localDateTime, zone).toInstant();
}
// toZonedDateTime
// #endregion
// #region - toZonedDateTime
/**
*
@ -338,7 +350,9 @@ public class DateTimeTools {
return ZonedDateTime.of(localDateTime, zone);
}
// toLocalDateTime
// #endregion
// #region - toLocalDateTime
/**
*
@ -406,9 +420,11 @@ public class DateTimeTools {
return LocalDateTime.ofInstant(zonedDateTime.toInstant(), zone);
}
// #endregion
// ====================
// toJodaInstant
// #region - toJodaInstant
/**
* {@link java.time.Instant} {@link org.joda.time.Instant}
@ -441,7 +457,9 @@ public class DateTimeTools {
return toJodaInstant(java.time.ZonedDateTime.of(localDateTime, zone));
}
// toJavaInstant
// #endregion
// #region - toJavaInstant
/**
* {@link org.joda.time.Instant} {@link java.time.Instant}
@ -479,7 +497,9 @@ public class DateTimeTools {
return toJavaInstant(localDateTime.toDateTime(zone));
}
// toJodaDateTime
// #endregion
// #region - toJodaDateTime
/**
* Java {@link java.time.ZonedDateTime}
@ -506,7 +526,7 @@ public class DateTimeTools {
public static org.joda.time.DateTime toJodaDateTime(
java.time.LocalDateTime localDateTime,
java.time.ZoneId zone) {
org.joda.time.DateTimeZone dateTimeZone = toJodaTime(zone);
org.joda.time.DateTimeZone dateTimeZone = toJodaZone(zone);
return toJodaInstant(ZonedDateTime.of(localDateTime, zone).toInstant()).toDateTime(dateTimeZone);
}
@ -520,11 +540,13 @@ public class DateTimeTools {
public static org.joda.time.DateTime toJodaDateTime(
java.time.Instant instant,
java.time.ZoneId zone) {
org.joda.time.DateTimeZone dateTimeZone = toJodaTime(zone);
org.joda.time.DateTimeZone dateTimeZone = toJodaZone(zone);
return toJodaInstant(instant).toDateTime(dateTimeZone);
}
// toZonedDateTime
// #endregion
// #region - toZonedDateTime
/**
* joda-time java.time
@ -568,7 +590,9 @@ public class DateTimeTools {
return toJavaInstant(instant).atZone(zone);
}
// toJodaLocalDateTime
// #endregion
// #region - toJodaLocalDateTime
/**
* {@link java.time.LocalDateTime} {@link org.joda.time.LocalDateTime}
@ -578,11 +602,13 @@ public class DateTimeTools {
*/
public static org.joda.time.LocalDateTime toJodaLocalDateTime(java.time.LocalDateTime localDateTime) {
java.time.ZoneId javaZone = java.time.ZoneId.systemDefault();
org.joda.time.DateTimeZone jodaZone = toJodaTime(javaZone);
org.joda.time.DateTimeZone jodaZone = toJodaZone(javaZone);
return toJodaInstant(localDateTime, javaZone).toDateTime(jodaZone).toLocalDateTime();
}
// toJavaLocalDateTime
// #endregion
// #region - toJavaLocalDateTime
/**
* {@link org.joda.time.LocalDateTime} {@link java.time.LocalDateTime}
@ -596,6 +622,10 @@ public class DateTimeTools {
return toJavaInstant(localDateTime, jodaZone).atZone(javaZone).toLocalDateTime();
}
// #endregion
// #region - ZoneId <--> DateTimeZone
/**
* Java API joda-time API
*
@ -612,11 +642,13 @@ public class DateTimeTools {
* @param zone Java API
* @return joda-time API
*/
public static org.joda.time.DateTimeZone toJodaTime(java.time.ZoneId zone) {
public static org.joda.time.DateTimeZone toJodaZone(java.time.ZoneId zone) {
return org.joda.time.DateTimeZone.forID(zone.getId());
}
// getQuarter
// #endregion
// #region - YearQuarter & Quarter
/**
*
@ -679,6 +711,8 @@ public class DateTimeTools {
return YearQuarter.of(date);
}
// #endregion
/**
*
*/