Created
January 7, 2014 00:09
-
-
Save kinow/8292426 to your computer and use it in GitHub Desktop.
note to self: ask britter later
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.commons.lang3; | |
import java.util.Calendar; | |
import java.util.TimeZone; | |
import org.apache.commons.lang3.time.DurationFormatUtils; | |
public class BRUNO { | |
private static void assertEqualDuration(final String message, final String expected, final int[] start, final int[] end, final String format) { | |
final Calendar cal1 = Calendar.getInstance(); | |
cal1.set(start[0], start[1], start[2], start[3], start[4], start[5]); | |
cal1.set(Calendar.MILLISECOND, 0); | |
final Calendar cal2 = Calendar.getInstance(); | |
cal2.set(end[0], end[1], end[2], end[3], end[4], end[5]); | |
cal2.set(Calendar.MILLISECOND, 0); | |
final long milli1 = cal1.getTime().getTime(); | |
final long milli2 = cal2.getTime().getTime(); | |
final String result = DurationFormatUtils.formatPeriod(milli1, milli2, format); | |
if (!expected.equals(result)) { | |
throw new RuntimeException(result + " different than " + expected); | |
} | |
} | |
public static void main2(String[] args) { | |
BRUNO.assertEqualDuration(null, "77", new int[] { 2005, 9, 16, 0, 0, 0 }, | |
new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); | |
} | |
public static void main(String[] args) { | |
Calendar cal = Calendar.getInstance(TimeZone.getDefault()); | |
cal.set(2005, 9, 16, 0, 0, 0); | |
System.out.println(cal.get(Calendar.HOUR_OF_DAY)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment