当前位置: 首页>>代码示例>>Java>>正文


Java LocalTime.now方法代码示例

本文整理汇总了Java中org.joda.time.LocalTime.now方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.now方法的具体用法?Java LocalTime.now怎么用?Java LocalTime.now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.now方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findCurrentLessonNo

import org.joda.time.LocalTime; //导入方法依赖的package包/类
private Optional<Integer> findCurrentLessonNo(List<LessonRange> ranges) {
    LocalTime now = LocalTime.now();

    for (int i = 0; i < ranges.size(); i++) {
        LessonRange range = ranges.get(i);
        if (!range.to().isPresent()) {
            continue;
        }
        if (range.to().get().compareTo(now) > 0) {
            return Optional.of(i);
        }
    }
    return Optional.absent();
}
 
开发者ID:shymmq,项目名称:librus-client,代码行数:15,代码来源:TimetablePresenter.java

示例2: setLocation

import org.joda.time.LocalTime; //导入方法依赖的package包/类
public void setLocation(Location location, double qiblaAngle) {
    if (location == null) return;
    mPrayTimes.setCoordinates(location.getLatitude(), location.getLongitude(), 0);
    mQiblaAngle = qiblaAngle;
    mQiblaTime = mPrayTimes.getQiblaTime();
    LocalTime sunrise = LocalTime.parse(mPrayTimes.getTime(Constants.TIMES_SUNRISE));
    LocalTime sunset = LocalTime.parse(mPrayTimes.getTime(Constants.TIMES_SUNSET));
    LocalTime current = LocalTime.now();

    mShowSun = !(sunset.isBefore(current) || sunrise.isAfter(current));

    mSunriseAngle = Math.toDegrees(getAzimuth(sunrise.toDateTimeToday().getMillis(), location.getLatitude(), location.getLongitude())) - qiblaAngle - 90;
    mSunsetAngle = Math.toDegrees(getAzimuth(sunset.toDateTimeToday().getMillis(), location.getLatitude(), location.getLongitude())) - qiblaAngle - 90;
    mCurrentAngle = Math.toDegrees(getAzimuth(current.toDateTimeToday().getMillis(), location.getLatitude(), location.getLongitude())) - qiblaAngle - 90;
}
 
开发者ID:metinkale38,项目名称:prayer-times-android,代码行数:16,代码来源:QiblaTimeView.java

示例3: isBreakOverMidnight

import org.joda.time.LocalTime; //导入方法依赖的package包/类
private boolean isBreakOverMidnight(TimeTrack timeTrack, Break breakToCheck) {
    // if timeTrack is not over midnight, also break can't be over midnight
    DateTime timeTrackStart = timeTrack.getFrom();
    DateTime timeTrackEnd = timeTrack.getTo() == null ? DateTime.now() : timeTrack.getTo();
    if(timeTrackEnd.isBefore(DateTimeUtils.endOfDay(timeTrackStart))) {
        return false;
    }
    // but if timeTrack is over midnight, we have also to check break
    LocalTime breakStart = breakToCheck.getFrom().toLocalTime();
    LocalTime breakEnd = breakToCheck.getTo() == null ? LocalTime.now() : breakToCheck.getTo().toLocalTime();
    if(breakStart.isBefore(breakEnd)) {
        return false;
    }
    return true;
}
 
开发者ID:peerdavid,项目名称:ComeAndGo,代码行数:16,代码来源:CollectiveAgreementImpl.java

示例4: testGetRelativeDateTimeString

import org.joda.time.LocalTime; //导入方法依赖的package包/类
public void testGetRelativeDateTimeString() {
    Context ctx = getInstrumentation().getContext();

    assertEquals("0 seconds ago, 12:35", DateUtils.getRelativeDateTimeString(ctx, mNow, null, 0));
    assertEquals("in 30 seconds, 12:35", DateUtils.getRelativeDateTimeString(ctx, mNow.plusSeconds(30), null, 0));
    assertEquals("30 seconds ago, 12:34", DateUtils.getRelativeDateTimeString(ctx, mNow.minusSeconds(30), null, 0));
    assertEquals("in 30 minutes, 13:05", DateUtils.getRelativeDateTimeString(ctx, mNow.plusMinutes(30), null, 0));
    assertEquals("30 minutes ago, 12:05", DateUtils.getRelativeDateTimeString(ctx, mNow.minusMinutes(30), null, 0));
    assertEquals("in 3 hours, 15:35", DateUtils.getRelativeDateTimeString(ctx, mNow.plusHours(3), null, 0));
    assertEquals("3 hours ago, 09:35", DateUtils.getRelativeDateTimeString(ctx, mNow.minusHours(3), null, 0));
    assertEquals("Oct 25, 1995, 12:35", DateUtils.getRelativeDateTimeString(ctx, mNow.plusDays(3), null, 0));
    assertEquals("Oct 19, 1995, 12:35", DateUtils.getRelativeDateTimeString(ctx, mNow.minusDays(3), null, 0));

    // Test abbreviation
    assertEquals("in 30 secs, 12:35",
        DateUtils.getRelativeDateTimeString(ctx, mNow.plusSeconds(30), null, DateUtils.FORMAT_ABBREV_RELATIVE));
    assertEquals("30 secs ago, 12:34",
        DateUtils.getRelativeDateTimeString(ctx, mNow.minusSeconds(30), null, DateUtils.FORMAT_ABBREV_RELATIVE));

    // Test transition resolution
    DateTime dt = DateTime.now().plusDays(2);
    assertEquals("in 2 days, 12:35", DateUtils.getRelativeDateTimeString(ctx, dt, Days.TWO, 0));
    assertEquals("Oct 24, 1995, 12:35", DateUtils.getRelativeDateTimeString(ctx, dt.plusSeconds(1), Days.TWO, 0));
    assertEquals("in 2 days, 12:35", DateUtils.getRelativeDateTimeString(ctx, dt, Days.THREE, 0));

    // Test partial input
    LocalTime lt = LocalTime.now();
    assertEquals("in 30 seconds, 12:35", DateUtils.getRelativeDateTimeString(ctx, lt.plusSeconds(30), null, 0));
    assertEquals("30 seconds ago, 12:34", DateUtils.getRelativeDateTimeString(ctx, lt.minusSeconds(30), null, 0));
    assertEquals("in 30 minutes, 13:05", DateUtils.getRelativeDateTimeString(ctx, lt.plusMinutes(30), null, 0));
    assertEquals("30 minutes ago, 12:05", DateUtils.getRelativeDateTimeString(ctx, lt.minusMinutes(30), null, 0));

    // Test bad partial input
    try {
        assertEquals("Oct 24, 1995, 12:35", DateUtils.getRelativeDateTimeString(ctx, LocalDate.now(), null, 0));
        fail("DateUtils.getRelativeDateTimeString() should have thrown an error since LocalDate has no time.");
    }
    catch (Exception e) {

    }
}
 
开发者ID:BenAlderfer,项目名称:RIT-Dining-Planner-Android,代码行数:42,代码来源:TestDateUtils.java


注:本文中的org.joda.time.LocalTime.now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。