public static Date parseLocalDateTime(String text, DateTimeFormatter formatter) { return toDate(LocalDateTime.parse(text, formatter)); }
public void write(String str, Date date) { byte[] text = (str + CL).getBytes(charset); try { initializeBufferedWriter(date, text.length); bufferedOutputStream.write(text); writeSize += text.length; lastWriteTime = TimeUtils.toLocalDateTime(date); } catch (IOException e) { System.err.println("write log exception, " + e.getMessage()); } }
private void initializeBufferedWriter(Date newDate, long currentWriteSize) throws IOException { LocalDateTime newLocalDateTime = TimeUtils.toLocalDateTime(newDate); String logName = getLogName(newLocalDateTime); Path logPath = Paths.get(path, logName); if (Files.exists(logPath)) { if (lastWriteTime == null) { FileTime fileTime = Files.getLastModifiedTime(logPath); lastWriteTime = LocalDateTime.from(fileTime.toInstant().atZone(ZoneId.systemDefault())); } if (!isNotOverTimeLimit(newLocalDateTime)) { initOutputStreamAndNewFile(logName, logPath, lastWriteTime); } else { if (maxFileSize > 0) { if (writeSize == 0) { writeSize = Files.size(logPath); } if ((currentWriteSize + writeSize) > maxFileSize) { initOutputStreamAndNewFile(logName, logPath, lastWriteTime); } else { initOutputStream(logName); } } else { initOutputStream(logName); } } } else { initOutputStream(logName); } }
public static Date parseLocalDate(String text, DateTimeFormatter formatter) { return toDate(LocalDate.parse(text, formatter)); }
public static Date parseLocalDate(String text, DateTimeFormatter formatter) { return toDate(LocalDate.parse(text, formatter)); }
public static Date parseLocalDateTime(String text, DateTimeFormatter formatter) { return toDate(LocalDateTime.parse(text, formatter)); }