本文整理汇总了Java中org.joda.time.ReadableInstant.getMillis方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableInstant.getMillis方法的具体用法?Java ReadableInstant.getMillis怎么用?Java ReadableInstant.getMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.ReadableInstant
的用法示例。
在下文中一共展示了ReadableInstant.getMillis方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
/**
* Compares this object with the specified object for ascending
* millisecond instant order. This ordering is inconsistent with
* equals, as it ignores the Chronology.
* <p>
* All ReadableInstant instances are accepted.
*
* @param other a readable instant to check against
* @return negative value if this is less, 0 if equal, or positive value if greater
* @throws NullPointerException if the object is null
* @throws ClassCastException if the object type is not supported
*/
public int compareTo(ReadableInstant other) {
if (this == other) {
return 0;
}
long otherMillis = other.getMillis();
long thisMillis = getMillis();
// cannot do (thisMillis - otherMillis) as can overflow
if (thisMillis == otherMillis) {
return 0;
}
if (thisMillis < otherMillis) {
return -1;
} else {
return 1;
}
}
示例2: roundDays
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
public static DateTime roundDays(ReadableInstant dt) {
long millisPerDay = DateTimeConstants.MILLIS_PER_DAY;
long t = dt.getMillis() / millisPerDay * millisPerDay;
// Keep TimeZone and round floor to a day
return new DateTime(t, dt.getZone()).dayOfMonth().roundFloorCopy();
}
示例3: roundWeek
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
public static DateTime roundWeek(ReadableInstant dt) {
long millisPerWeek = DateTimeConstants.MILLIS_PER_WEEK;
long t = dt.getMillis() / millisPerWeek * millisPerWeek;
// Keep TimeZone and round floor to a day
return new DateTime(t, dt.getZone()).weekOfWeekyear().roundFloorCopy();
}
示例4: handleCalendarIntegration
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
private void handleCalendarIntegration() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
Prefs.setCalendar("-1");
return;
}
Context context = App.get();
try {
ContentResolver cr = context.getContentResolver();
cr.delete(CalendarContract.Events.CONTENT_URI, CalendarContract.Events.DESCRIPTION + "=\"com.metinkale.prayer\"", null);
String id = Prefs.getCalendar();
if ("-1".equals(id)) {
return;
}
int year = LocalDate.now().getYear();
Collection<int[]> days = new ArrayList<>();
days.addAll(HicriDate.getHolydays(year));
days.addAll(HicriDate.getHolydays(year + 1));
int i = 0;
ContentValues[] events = new ContentValues[days.size()];
for (int[] date : days) {
ContentValues event = new ContentValues();
event.put(CalendarContract.Events.CALENDAR_ID, id);
event.put(CalendarContract.Events.TITLE, Utils.getHolyday(date[HicriDate.DAY] - 1));
event.put(CalendarContract.Events.DESCRIPTION, "com.metinkale.prayer");
ReadableInstant cal = new DateTime(date[HicriDate.GY], date[HicriDate.GM], date[HicriDate.GD], 0, 0, 0);
long dtstart = cal.getMillis();
long dtend = dtstart + DateUtils.DAY_IN_MILLIS;
event.put(CalendarContract.Events.DTSTART, dtstart + TimeZone.getDefault().getOffset(dtstart));
event.put(CalendarContract.Events.DTEND, dtend + TimeZone.getDefault().getOffset(dtend));
event.put(CalendarContract.Events.EVENT_TIMEZONE, Time.TIMEZONE_UTC);
event.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CONFIRMED);
event.put(CalendarContract.Events.ALL_DAY, 1);
events[i] = event;
i++;
}
cr.bulkInsert(CalendarContract.Events.CONTENT_URI, events);
} catch (Exception e) {
Prefs.setCalendar("-1");
Crashlytics.logException(e);
}
}
示例5: FakeClock
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
/**
* Creates a FakeClock instance initialized to the given time.
*/
public FakeClock(ReadableInstant now) {
baseTimeMs = now.getMillis();
fakeNowMs = new AtomicLong(baseTimeMs);
}
示例6: writeTime
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
@Override
public double writeTime(ReadableInstant time) {
return time.getMillis();
}
示例7: equals
import org.joda.time.ReadableInstant; //导入方法依赖的package包/类
/**
* Compares this object with the specified object for equality based
* on the millisecond instant, chronology and time zone.
* <p>
* Two objects which represent the same instant in time, but are in
* different time zones (based on time zone id), will be considered to
* be different. Only two objects with the same {@link DateTimeZone},
* {@link Chronology} and instant are equal.
* <p>
* See {@link #isEqual(ReadableInstant)} for an equals method that
* ignores the Chronology and time zone.
* <p>
* All ReadableInstant instances are accepted.
*
* @param readableInstant a readable instant to check against
* @return true if millisecond and chronology are equal, false if
* not or the instant is null or of an incorrect type
*/
public boolean equals(Object readableInstant) {
// must be to fulfil ReadableInstant contract
if (this == readableInstant) {
return true;
}
if (readableInstant instanceof ReadableInstant == false) {
return false;
}
ReadableInstant otherInstant = (ReadableInstant) readableInstant;
return
getMillis() == otherInstant.getMillis() &&
FieldUtils.equals(getChronology(), otherInstant.getChronology());
}