Browse Source

docs: adding more details and fix formatting

pull/2651/head
amin 4 months ago committed by zanninso
parent
commit
a7e7a03e7a
  1. 12
      subjects/java/checkpoints/date-formatter/README.md

12
subjects/java/checkpoints/date-formatter/README.md

@ -4,17 +4,15 @@
Write a class `DateFormatter` that has three private attributes: Write a class `DateFormatter` that has three private attributes:
- `date`: the date to be formatted (as a date). - `date`: the date to be formatted (as a UNIX time in seconds).
- `format`: the format to convert the date to. - `format`: the format to convert the date to.
- `formattedDate`: contains the date converted into the given format. - `formattedDate`: contains the date converted into the given format.
Create getters for all the attributes and setters for `date` and `format`. The conversion should happen when you set the `format` or the `date`. If the `format` is not correct, the conversion shouldn't happen. Additionally, create methods to output the date in the specified `format`, and constructors with only the `date`, with `date` and `format`, and a default constructor. Create getters for all the attributes and setters for `date` and `format`. The conversion should happen when you set the `format` or the `date`. If the `format` is not correct, the conversion shouldn't happen. Additionally, create methods to output the date in the specified `format`, and constructors with only the `date`, with `date` and `format`, and a default constructor.
#### The accepted date formats are: The default date is the current date, and the format as follow `DD/MM/YYYY`.
- `DD/MM/YYYY` > Using standart library to convert UNIX time to date is allowed
- `DD Month YYYY`
- `DD.MM.YYYY`
#### The accepted date formats are: #### The accepted date formats are:
@ -29,7 +27,7 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class DateFormatter { public class DateFormatter {
private long timestamp; private long date;
private String formattedDate; private String formattedDate;
private String format; private String format;
@ -39,7 +37,7 @@ public class DateFormatter {
### Usage ### Usage
Here is a possible ExerciseRunner.java to test your class: Here is a possible `ExerciseRunner.java` to test your class:
```java ```java
public class ExerciseRunner { public class ExerciseRunner {

Loading…
Cancel
Save