Commit b83f1a4a authored by Ondřej Hrdlička's avatar Ondřej Hrdlička
Browse files

Moved formatting out of Category.java

parent ec1ed313
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
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()
+5 −1
Original line number Diff line number Diff line
@@ -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) {
+0 −1
Original line number Diff line number Diff line
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}
+0 −2
Original line number Diff line number Diff line
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}