-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimebox.java
66 lines (55 loc) · 1.61 KB
/
timebox.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.time.*;
import java.time.format.*;
import java.io.File;
import java.io.FileWriter;
import java.util.Locale;
class TimeboxCreator{
LocalTime start;
LocalTime end;
public TimeboxCreator(String startTime, String endTime){
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_TIME;
this.start = LocalTime.parse(startTime, dateTimeFormatter);
this.end = LocalTime.parse(endTime, dateTimeFormatter);
}
public void createStringTimebox() throws Exception{
File file = new File(".\\timebox.txt");
FileWriter fw = new FileWriter(file);
fw.write("Timebox \n");
Locale l = Locale.getDefault();
String country = l.getDisplayCountry();
fw.write(country + " " + LocalDate.now() + "\n");
fw.write("-----------------------------------------\n");
LocalTime tmp = start;
for (int position = 0;tmp.isBefore(end);position++){
fw.write(tmp +" - " + tmp.plusMinutes(25) + " || \n");
if (position%4 == 3){
tmp = tmp.plusMinutes(60);
fw.write("-----------------------------------------\n");
}else{
tmp = tmp.plusMinutes(30);
}
}
fw.close();
}
public static void main(String[] args) throws Exception{
String start, end;
if (args == null || args.length == 0){
start = "08:00";
end = "16:00";
}else{
start = fill(args[0]);
end = fill(args[1]);
}
TimeboxCreator tc = new TimeboxCreator(start, end);
tc.createStringTimebox();
}
private static String fill(String s){
if(!s.contains(":")){
s += ":00";
}
while(s.length() < 5){
s = "0"+s;
}
return s;
}
}