@Test public void testEquals() { System.out.println("equals"); Object obj = new TimePeriod(time1, time2); TimePeriod instance = new TimePeriod(time1, time2); boolean expResult = true; boolean result = instance.equals(obj); assertEquals(expResult, result); obj = new TimePeriod(time2, new GregorianCalendar()); expResult = false; result = instance.equals(obj); assertEquals(expResult, result); }
@Override public boolean equals(Object obj) { if (obj instanceof TimePeriod) { TimePeriod comp = (TimePeriod) obj; return (startTime.equals(comp.startTime) && endTime.equals(comp.endTime)); } else { return false; } }
TimePeriod implements Comparable<TimePeriod> { @Override public boolean equals(Object obj) { if (obj instanceof TimePeriod) { TimePeriod comp = (TimePeriod) obj; return (startTime.equals(comp.startTime) && endTime.equals(comp.endTime)); } else { return false; } } }
TimePeriod implements Comparable<TimePeriod> { @Override public boolean equals(Object obj) { if (obj instanceof TimePeriod) { TimePeriod comp = (TimePeriod) obj; return (startTime.equals(comp.startTime) && endTime.equals(comp.endTime)); } else { return false; } } TimePeriod(long startTime, long endTime);  TimePeriod(Calendar startTime, Calendar endTime);  TimePeriod(Calendar startTime, long seconds);  TimePeriod(Calendar startTime, int time, TimeUnit sourceUnit);  TimePeriod(int time, TimeUnit sourceUnit); }
TimePeriod implements Comparable<TimePeriod> { @Override public boolean equals(Object obj) { if (obj instanceof TimePeriod) { TimePeriod comp = (TimePeriod) obj; return (startTime.equals(comp.startTime) && endTime.equals(comp.endTime)); } else { return false; } } TimePeriod(long startTime, long endTime);  TimePeriod(Calendar startTime, Calendar endTime);  TimePeriod(Calendar startTime, long seconds);  TimePeriod(Calendar startTime, int time, TimeUnit sourceUnit);  TimePeriod(int time, TimeUnit sourceUnit); long getDuration(); static long convertToMinutes(TimePeriod duration); static long convertToHours(TimePeriod duration); static long convertToDays(TimePeriod duration); Calendar getStartTime(); long getStartTimeInSeconds(); Calendar getEndTime(); long getEndTimeInSeconds(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(TimePeriod other); @Override String toString(); boolean isValid(); }
TimePeriod implements Comparable<TimePeriod> { @Override public boolean equals(Object obj) { if (obj instanceof TimePeriod) { TimePeriod comp = (TimePeriod) obj; return (startTime.equals(comp.startTime) && endTime.equals(comp.endTime)); } else { return false; } } TimePeriod(long startTime, long endTime);  TimePeriod(Calendar startTime, Calendar endTime);  TimePeriod(Calendar startTime, long seconds);  TimePeriod(Calendar startTime, int time, TimeUnit sourceUnit);  TimePeriod(int time, TimeUnit sourceUnit); long getDuration(); static long convertToMinutes(TimePeriod duration); static long convertToHours(TimePeriod duration); static long convertToDays(TimePeriod duration); Calendar getStartTime(); long getStartTimeInSeconds(); Calendar getEndTime(); long getEndTimeInSeconds(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(TimePeriod other); @Override String toString(); boolean isValid();  }