Skip to content
Snippets Groups Projects
Commit b83f1a4a authored by Ondřej Hrdlička's avatar Ondřej Hrdlička
Browse files

Moved formatting out of Category.java

parent ec1ed313
No related branches found
No related tags found
2 merge requests!52Final project MR,!51M02review
package cz.muni.fi.pv168.project.data.category;
import cz.muni.fi.pv168.project.data.IdentifiableEntity;
import cz.muni.fi.pv168.project.ui.i18n.I18N;
import java.awt.*;
import java.time.Duration;
......@@ -12,8 +11,6 @@ import java.util.Objects;
public class Category implements IdentifiableEntity {
private static final I18N I18N = new I18N(Category.class);
private Long id;
private String name;
private Color color;
......@@ -46,10 +43,6 @@ public class Category implements IdentifiableEntity {
return this.name;
}
public String getTimeDurationFormatted(LocalDate fromDate, LocalDate toDate) {
return getTotalDuration(fromDate, toDate).toHours() + " hours";
}
public Duration getTotalDuration(LocalDate fromDate, LocalDate toDate) {
return this.timeSpents
.stream()
......
......@@ -41,12 +41,16 @@ public class CategoryStatisticsTableModel extends AbstractTableModel implements
case 0:
return category;
case 1:
return category.getTimeDurationFormatted(fromDate, toDate);
return getTimeDurationFormatted(category);
default:
throw new IndexOutOfBoundsException("Invalid column index: " + columnIndex);
}
}
public String getTimeDurationFormatted(Category category) {
return category.getTotalDuration(fromDate, toDate).toHours() + " hours";
}
@Override
public String getColumnName(int columnIndex) {
switch (columnIndex) {
......
Category.timePeriodFormat={0,choice,0#|1#1 day|1<{0,number,integer} days} {1,choice,0#0 hours|1#1 hour|1<{1,number,integer} hours}
Category.timePeriodFormat={0,choice,0#|1#1 den|1<{0,number,integer} dny|4<{0,number,integer} dn\u016F} \
{1,choice,0#0 hodin|1#1 hodina|1<{1,number,integer} hodiny|4<{1,number,integer} hodin}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment