Mercurial Hosting > luan
annotate src/goodjava/logger/DateLayout.java @ 1759:6668513a11d7
fix PUT
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 10 Apr 2023 17:43:47 -0600 |
| parents | 6fc083e1d08c |
| children | 1cdc12cdcfa2 |
| rev | line source |
|---|---|
| 1448 | 1 package goodjava.logger; |
| 2 | |
| 3 import java.text.DateFormat; | |
| 4 import java.text.SimpleDateFormat; | |
| 5 import java.util.Date; | |
| 6 | |
| 7 | |
| 8 public final class DateLayout implements Layout { | |
| 9 private final Date date = new Date(); | |
| 10 private final DateFormat dateFormat; | |
| 11 | |
| 12 public DateLayout(String pattern) { | |
| 13 dateFormat = new SimpleDateFormat(pattern); | |
| 14 } | |
| 15 | |
| 16 public synchronized String format(LoggingEvent event) { | |
| 17 date.setTime(event.time); | |
| 18 return dateFormat.format(date); | |
| 19 } | |
| 20 } |
