This commit is contained in:
xzb 2022-12-09 13:18:30 +08:00
parent 89d20afa7f
commit 4a95a12fee
3 changed files with 4 additions and 22 deletions

View File

@ -1,15 +0,0 @@
package club.joylink.rtss.iscs.convert;
import com.google.protobuf.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
public class LocalDateTimeConvertor {
/**
* @param zoneOffset 如ZoneOffset.ofHours(8) 东8区
*/
public static LocalDateTime convertFrom(Timestamp from,ZoneOffset zoneOffset){
return LocalDateTime.ofEpochSecond(from.getSeconds(),from.getNanos(), zoneOffset);
}
}

View File

@ -10,6 +10,9 @@ import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.TimeZone;
/**
* java 时间与 proto时间间的相互转换
*/
@Component
public class TimeProtoConvertor {
private static TimeZone timeZone;
@ -28,11 +31,4 @@ public class TimeProtoConvertor {
public static LocalDateTime convertFrom(Timestamp from) {
return LocalDateTime.ofInstant(Instant.ofEpochSecond(from.getSeconds(), from.getNanos()), timeZone.toZoneId());
}
public static void main(String[] args) {
final Timestamp.Builder timestamp = convertFrom(LocalDateTime.now());
System.out.println(timestamp.build().toString());
final LocalDateTime now = convertFrom(timestamp.build());
System.out.println(now.toString());
}
}

View File

@ -35,6 +35,7 @@ public class MemoryManager {
private LinkedList<SoeProto.AlarmEvent.Builder> alarmEvents = new LinkedList<>();
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 添加产生的动作事件
*/