Skip to content

Commit

Permalink
see 04/21 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Apr 21, 2017
1 parent 9468a64 commit 0572bf7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion utilcode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ dependencies {
testCompile "com.google.truth:truth:$TRUTH_VERSION"
testCompile "org.robolectric:robolectric:$ROBOLECTRIC_VERSION"
}
//apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
//gradlew bintrayUpload
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ public static Date getDate(Date date, long timeSpan, @TimeConstants.Unit int uni
* @return 与当前时间等于时间差的时间戳
*/
public static long getMillisByNow(long timeSpan, @TimeConstants.Unit int unit) {
return getNowMills() + timeSpan2Millis(timeSpan, unit);
return getMillis(getNowMills(), timeSpan, unit);
}

/**
Expand Down Expand Up @@ -1069,7 +1069,7 @@ public static String getStringByNow(long timeSpan, @TimeConstants.Unit int unit)
* @return 与当前时间等于时间差的时间字符串
*/
public static String getStringByNow(long timeSpan, @TimeConstants.Unit int unit, String pattern) {
return millis2String(getNowMills() + timeSpan2Millis(timeSpan, unit), pattern);
return getString(getNowMills(), pattern, timeSpan, unit);
}

/**
Expand All @@ -1087,7 +1087,7 @@ public static String getStringByNow(long timeSpan, @TimeConstants.Unit int unit,
* @return 与当前时间等于时间差的Date
*/
public static Date getDateByNow(long timeSpan, @TimeConstants.Unit int unit) {
return millis2Date(getNowMills() + timeSpan2Millis(timeSpan, unit));
return getDate(getNowMills(), timeSpan, unit);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class TimeUtilsTest {
long millis = 1470991049000L;
Date timeDate = new Date(millis);
String timeString = "2016-08-12 16:37:29";
String tomorrowTimeString = "2016-08-13 16:37:29";
String myTimeString = "2016-08-12 16:37:29 中国标准时间";
String timeString0 = "2016-08-12 16:00:00";
String timeString1 = "2016-08-12 17:10:10";
Expand Down Expand Up @@ -93,6 +94,11 @@ public void testGetFriendlyTimeSpanByNow() throws Exception {
System.out.println(getFriendlyTimeSpanByNow(System.currentTimeMillis() - 2 * TimeConstants.DAY));
}

@Test
public void testGetString() throws Exception {
assertThat(tomorrowTimeString).isEqualTo(getString(millis, 1, TimeConstants.DAY));
}

@Test
public void testIsSameDay() throws Exception {
System.out.println(isSameDay(System.currentTimeMillis()));
Expand Down

0 comments on commit 0572bf7

Please sign in to comment.