类 JDateUtil
- java.lang.Object
-
- org.meteoinfo.common.util.JDateUtil
-
public class JDateUtil extends Object
-
-
构造器概要
构造器 构造器 说明 JDateUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static DateasDate(LocalDate localDate)Convert LocalDate to Date object.static DateasDate(LocalDateTime localDateTime)Convert LocalDateTime to Date object.static LocalDateasLocalDate(Date date)Convert Date to LocalDate object.static LocalDateTimeasLocalDateTime(long ms)Convert milli seconds to LocalDateTime object.static LocalDateTimeasLocalDateTime(Date date)Convert Date to LocalDateTime object.static longasMilliSeconds(LocalDateTime ldt)Convert LocalDateTime to milli secondsstatic intdayOfYear(int year, int month, int day)Get day of yearstatic LocalDatedoy2date(int year, int doy)Convert day of year to datestatic booleanequals(LocalDateTime a, LocalDateTime b)Date equalsstatic LocalDateTimefromOADate(double oaDate)Convert OA date to datestatic ChronoUnitgetChronoUnit(TemporalAmount ta)Get Chrono unitstatic StringgetDateFormat(TemporalAmount p)Get date format stringstatic LocalDateTimegetDateTime(String dts)Get date time from stringstatic LocalDateTimegetDateTime_(String dts)Get date time from stringstatic List<LocalDateTime>getDateTimes(int tNum, LocalDateTime end, TemporalAmount p)Get date time liststatic List<LocalDateTime>getDateTimes(LocalDateTime start, int tNum, TemporalAmount p)Get date time liststatic List<LocalDateTime>getDateTimes(LocalDateTime start, LocalDateTime end, TemporalAmount p)Get date time liststatic intgetDays(LocalDateTime t, LocalDateTime baseDate)Get days difference between two datesstatic intgetDaysOfMonth(int year, int month)Get days of a monthstatic intgetDaysOfYear(int year)Get days of a yearstatic intgetHours(LocalDateTime t, LocalDateTime baseDate)Get hours difference between two datesstatic TemporalAmountgetPeriod(String pStr)Get period from stringstatic ChronoUnitgetPeriodType(String p)Get period type from stringstatic intgetTimeDeltaValue(LocalDateTime t, LocalDateTime baseDate, String tDelta)Get time value - Time delta value of base datestatic List<Integer>getTimeDeltaValues(List<LocalDateTime> times, LocalDateTime baseDate, String tDelta)Get time values - Time delta values of base datestatic LocalDateTimeparseDateTime(String dtStr, DateTimeFormatter formatter)Parse string to LocalDateTimestatic LocalDateTimeparseDateTime_bak(String dtStr, DateTimeFormatter formatter)Parse string to LocalDateTimestatic doubletoOADate(LocalDateTime ldt)Convert LocalDateTime to OA date
-
-
-
方法详细资料
-
asDate
public static Date asDate(LocalDate localDate)
Convert LocalDate to Date object.- 参数:
localDate- The LocalDate object.- 返回:
- Date object.
-
asDate
public static Date asDate(LocalDateTime localDateTime)
Convert LocalDateTime to Date object.- 参数:
localDateTime- The LocalDateTime object.- 返回:
- Date object.
-
asLocalDate
public static LocalDate asLocalDate(Date date)
Convert Date to LocalDate object.- 参数:
date- The Date object.- 返回:
- LocalDate object.
-
asLocalDateTime
public static LocalDateTime asLocalDateTime(Date date)
Convert Date to LocalDateTime object.- 参数:
date- The Date object.- 返回:
- LocalDateTime object.
-
asLocalDateTime
public static LocalDateTime asLocalDateTime(long ms)
Convert milli seconds to LocalDateTime object.- 参数:
ms- The milli seconds.- 返回:
- LocalDateTime object.
-
fromOADate
public static LocalDateTime fromOADate(double oaDate)
Convert OA date to date- 参数:
oaDate- OA date- 返回:
- Date
-
asMilliSeconds
public static long asMilliSeconds(LocalDateTime ldt)
Convert LocalDateTime to milli seconds- 参数:
ldt- Local date time- 返回:
- Milli seconds
-
toOADate
public static double toOADate(LocalDateTime ldt)
Convert LocalDateTime to OA date- 参数:
ldt- Local date time- 返回:
- OA date
-
getDaysOfMonth
public static int getDaysOfMonth(int year, int month)Get days of a month- 参数:
year- The yearmonth- The month- 返回:
- The days in the month
-
getDaysOfYear
public static int getDaysOfYear(int year)
Get days of a year- 参数:
year- The year- 返回:
- The days in the year
-
getTimeDeltaValues
public static List<Integer> getTimeDeltaValues(List<LocalDateTime> times, LocalDateTime baseDate, String tDelta)
Get time values - Time delta values of base date- 参数:
times- Time listbaseDate- Base datetDelta- Time delta type - days/hours/...- 返回:
- The time delta values
-
getTimeDeltaValue
public static int getTimeDeltaValue(LocalDateTime t, LocalDateTime baseDate, String tDelta)
Get time value - Time delta value of base date- 参数:
t- The timebaseDate- Base datetDelta- Time delta type - days/hours/...- 返回:
- The time delta value
-
getDays
public static int getDays(LocalDateTime t, LocalDateTime baseDate)
Get days difference between two dates- 参数:
t- The timebaseDate- Base date- 返回:
- The time delta value
-
getHours
public static int getHours(LocalDateTime t, LocalDateTime baseDate)
Get hours difference between two dates- 参数:
t- The timebaseDate- Base date- 返回:
- The time delta value
-
equals
public static boolean equals(LocalDateTime a, LocalDateTime b)
Date equals- 参数:
a- Date ab- Date b- 返回:
- If equals
-
dayOfYear
public static int dayOfYear(int year, int month, int day)Get day of year- 参数:
year- Yearmonth- Monthday- Day- 返回:
- Day of year
-
doy2date
public static LocalDate doy2date(int year, int doy)
Convert day of year to date- 参数:
year- Yeardoy- Day of year- 返回:
- The date
-
getPeriodType
public static ChronoUnit getPeriodType(String p)
Get period type from string- 参数:
p- Period type string- 返回:
- PeriodType
-
getPeriod
public static TemporalAmount getPeriod(String pStr)
Get period from string- 参数:
pStr- Period string- 返回:
- Period
-
getChronoUnit
public static ChronoUnit getChronoUnit(TemporalAmount ta)
Get Chrono unit- 参数:
ta- The Temporal amount- 返回:
- Chrono unit
-
getDateFormat
public static String getDateFormat(TemporalAmount p)
Get date format string- 参数:
p- Period- 返回:
- Date format string
-
getDateTime
public static LocalDateTime getDateTime(String dts)
Get date time from string- 参数:
dts- Date time string- 返回:
- DateTime
-
getDateTime_
public static LocalDateTime getDateTime_(String dts)
Get date time from string- 参数:
dts- Date time string- 返回:
- DateTime
-
getDateTimes
public static List<LocalDateTime> getDateTimes(LocalDateTime start, LocalDateTime end, TemporalAmount p)
Get date time list- 参数:
start- Start date timeend- End date timep- Peroid- 返回:
- Date time list
-
getDateTimes
public static List<LocalDateTime> getDateTimes(LocalDateTime start, int tNum, TemporalAmount p)
Get date time list- 参数:
start- Start date timetNum- Date time numberp- Peroid- 返回:
- Date time list
-
getDateTimes
public static List<LocalDateTime> getDateTimes(int tNum, LocalDateTime end, TemporalAmount p)
Get date time list- 参数:
end- End date timetNum- Date time numberp- Peroid- 返回:
- Date time list
-
parseDateTime
public static LocalDateTime parseDateTime(String dtStr, DateTimeFormatter formatter)
Parse string to LocalDateTime- 参数:
dtStr- The stringformatter- DateTimeFormatter- 返回:
- LocalDateTime
-
parseDateTime_bak
public static LocalDateTime parseDateTime_bak(String dtStr, DateTimeFormatter formatter)
Parse string to LocalDateTime- 参数:
dtStr- The stringformatter- DateTimeFormatter- 返回:
- LocalDateTime
-
-