1 package org.netbeans.modules.tasklist.usertasks.model; 2 3 6 public class Duration { 7 public int weeks, days, hours, minutes; 8 9 16 public Duration(int weeks, int days, int hours, int minutes) { 17 this.weeks = weeks; 18 this.days = days; 19 this.hours = hours; 20 this.minutes = minutes; 21 } 22 23 30 public Duration(int minutes, int hoursPerDay, int daysPerWeek) { 31 this.minutes = minutes % 60; 32 minutes /= 60; 33 this.hours = minutes % hoursPerDay; 34 minutes /= hoursPerDay; 35 this.days = minutes % daysPerWeek; 36 minutes /= daysPerWeek; 37 this.weeks = minutes; 38 } 39 40 48 public Duration(int minutes, int minutesPerDay, int daysPerWeek, 49 boolean ignored) { 50 this.minutes = minutes % minutesPerDay; 51 this.hours = this.minutes / 60; 52 this.minutes = this.minutes % 60; 53 54 this.days = minutes / minutesPerDay; 55 this.weeks = this.days / daysPerWeek; 56 this.days = this.days % daysPerWeek; 57 } 58 59 65 public int toMinutes(int hoursPerDay, int daysPerWeek) { 66 return ((weeks * daysPerWeek + days) * hoursPerDay + hours) * 60 + 67 minutes; 68 } 69 70 77 public int toMinutes(int minutesPerDay, int daysPerWeek, boolean ignore) { 78 return (weeks * daysPerWeek + days) * minutesPerDay + hours * 60 + 79 minutes; 80 } 81 82 public boolean equals(Object obj) { 83 if (!(obj instanceof Duration)) 84 return false; 85 Duration d = (Duration) obj; 86 return d.weeks == weeks && d.days == days && d.hours == hours && 87 d.minutes == minutes; 88 } 89 } 90 | Popular Tags |