谢茂盛
authored
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package com.canrd.webmagic.common.utils;
import org.joda.time.DateTime;
import java.time.LocalDateTime;
/**
* @author: xms
* @description: TODO
* @date: 2023/1/16 16:35
* @version: 1.0
*/
public class LocalDateTimeUtil {
/**
* @param dateTime
* @return
*/
public static LocalDateTime toLocalDateTime(DateTime dateTime) {
return LocalDateTime.of(dateTime.getYear(), dateTime.getMonthOfYear(),
dateTime.getDayOfMonth(), dateTime.getHourOfDay(),
dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute());
}
/**
*
* @param localDateTime
* @return
*/
public static DateTime toDateTime(LocalDateTime localDateTime) {
return new DateTime().withYear(localDateTime.getYear()).withMonthOfYear(localDateTime.getMonthValue())
.withDayOfMonth(localDateTime.getDayOfMonth()).withHourOfDay(localDateTime.getHour())
.withMinuteOfHour(localDateTime.getMinute()).withSecondOfMinute(localDateTime.getSecond());
}
}
|