我的问题是。我正在编写一个程序来进行预订。为此,我使用 Filewriter 和 Buffered write 将其写入 txt 文件。输入是通过 simpleInoutDialog 输入的,它给出了一个带有模板 hh:mm:ss 的字符串。
我将此连同名称示例一起写入 txt 文件:
08:00:00
Tom Hanks
06:20:00
Henry Bigs
我想要做的是对日期进行排序以便我可以轻松阅读它?有什么帮助吗?
我的问题是。我正在编写一个程序来进行预订。为此,我使用 Filewriter 和 Buffered write 将其写入 txt 文件。输入是通过 simpleInoutDialog 输入的,它给出了一个带有模板 hh:mm:ss 的字符串。
我将此连同名称示例一起写入 txt 文件:
08:00:00
Tom Hanks
06:20:00
Henry Bigs
我想要做的是对日期进行排序以便我可以轻松阅读它?有什么帮助吗?
是的。使用log4j或slf4j或logback并制作模式:
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
<append>true</append>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%date{HH:mm:ss} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
框架将为您排序消息。