是否有一种方法可以将maindll.get_flash_value.argtypes = [c_int, c_int, c_char_p]
maindll.get_flash_value.restype = c_int
解析为# array of char of readlen, initialized to zero
data = (c_char * readlen)()
# call
maindll.get_flash_value(address, readlen, data)
# to get the data as bytes, say:
read_data = bytes(data)
。我正在尝试:
2018-09-17T17:13:13.741
通过组合,我要么获得解析异常,要么2018-09-17 17:13:13
。
注意:我不需要LocalDateTime startDateTime = LocalDateTime.now();
DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime.parse(startDateTime, FORMATTER);
和毫秒
答案 0 :(得分:4)
像这样使用format:
LocalDateTime startDateTime = LocalDateTime.now();
DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
startDateTime.format(FORMATTER);
答案 1 :(得分:0)
您可以直接使用LocalDateTime代替DateTimeFormatter来获取年,月,日,小时,分钟和秒。
以下代码可能适用于您的情况。
LocalDateTime startDateTime = LocalDateTime.now();
int year = startDateTime.getYear();
int month = startDateTime.getMonthValue();
int day = startDateTime.getDayOfMonth();
int hours = startDateTime.getHour();
int minute = startDateTime.getMinute();
int seconds = startDateTime.getSecond();
int nanoSeconds = startDateTime.getNano();
String date = year +"-"+month+"-"+day+" "+hours+":"+minute+":"+seconds;
System.out.println(date);