forked from alamkanak/Android-Week-View
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekViewUtil.java
More file actions
49 lines (41 loc) · 1.49 KB
/
Copy pathWeekViewUtil.java
File metadata and controls
49 lines (41 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.alamkanak.weekview;
import java.util.Calendar;
/**
* Created by jesse on 6/02/2016.
*/
public class WeekViewUtil {
/////////////////////////////////////////////////////////////////
//
// Helper methods.
//
/////////////////////////////////////////////////////////////////
/**
* Checks if two times are on the same day.
* @param dayOne The first day.
* @param dayTwo The second day.
* @return Whether the times are on the same day.
*/
public static boolean isSameDay(Calendar dayOne, Calendar dayTwo) {
return dayOne.get(Calendar.YEAR) == dayTwo.get(Calendar.YEAR) && dayOne.get(Calendar.DAY_OF_YEAR) == dayTwo.get(Calendar.DAY_OF_YEAR);
}
private static Calendar sDayOne = Calendar.getInstance();
private static Calendar sDayTwo = Calendar.getInstance();
public static boolean isSameDay(long dayOne, long dayTwo) {
sDayOne.setTimeInMillis(dayOne);
sDayTwo.setTimeInMillis(dayTwo);
return isSameDay(sDayOne, sDayTwo);
}
private static final Calendar sToday = Calendar.getInstance();
/**
* Returns a calendar instance at the start of this day
* @return the calendar instance
*/
public static Calendar today(){
sToday.setTimeInMillis(System.currentTimeMillis());
sToday.set(Calendar.HOUR_OF_DAY, 0);
sToday.set(Calendar.MINUTE, 0);
sToday.set(Calendar.SECOND, 0);
sToday.set(Calendar.MILLISECOND, 0);
return sToday;
}
}