March 2018
Intermediate to advanced
208 pages
4h 52m
English
| | class Mission { |
| | |
| | Logbook logbook; |
| | LocalDate start; |
| | |
| | void update(String author, String message) { |
| | LocalDate today = LocalDate.now(); |
| | String month = String.valueOf(today.getMonthValue()); |
| | String formattedMonth = month.length() < 2 ? "0" + month : month; |
| » | String entry = author.toUpperCase() + ": [" + formattedMonth + "-" + |
| | today.getDayOfMonth() + "-" + today.getYear() + "](Day " + |
| | (ChronoUnit.DAYS.between(start, today) + 1) + ")> " + |
| | message + System.lineSeparator(); |
| | logbook.write(entry); |
| | } |
| | } |
Understandability and readability don’t just matter in your code—they’re also important for the output your code produces.
If you have to build large strings, you can use format strings ...
Read now
Unlock full access