I'm working at a code and I need to use Clock class to get the current time. And I want to subtract the current date with 2 months.
This is the code:
public class DemoApp {
private Clock clock = Clock.systemDefaultZone();
public List<String> subtractMonths(String[][] str) {
List<String> ids = new ArrayList<>();
// The code
return ids;
}
}
And in the main class I have this array of strings:
private static final String[][] str = {
{"id1", "2017-11-01T14:10:30"},
{"id2", "2018-01-20T18:01:34"},
{"id3", "2018-01-22T08:45:22"},
{"id4", "2018-02-18T12:42:37"},
{"id5", "2019-03-16T03:56:32"},
};
In the main class I'll call the subtractMonths
method with the str parameter and return the id if the date is not the current month and the previous month. For example if the current month is January only return id with month before December. Any feedback will be appreciated!