Java 类org.joda.time.LocalTime 实例源码

项目:jasperreports    文件:DateTimeFunctions.java   
public static String TIME(Integer hours, Integer minutes, Integer seconds, String timePattern){
    if(hours==null || minutes==null || seconds==null) {
        if(log.isDebugEnabled()){
            log.debug("None of the arguments can be null.");
        }
        return null;
    }
    LocalTime lt=new LocalTime(hours,minutes,seconds);
    if(timePattern==null) {
        return lt.toString(DateTimeFormat.longTime()); 
    }
    else{
        try{
            // Try to convert to a pattern
            DateTimeFormatter dtf = DateTimeFormat.forPattern(timePattern);
            return lt.toString(dtf);
        }
        catch (IllegalArgumentException ex){
            // Fallback to the default solution
            return lt.toString(DateTimeFormat.longTime()); 
        }           
    }
}
项目:yum    文件:MenusService.java   
private DateTime getDeadline(LocalDate date) {
    Settings settings = settingsRepo.findById(1);
    int deadlineDays = settings.getDeadlineDays();
    LocalTime deadlineTime = settings.getDeadline();

    date = date.minusDays(deadlineDays);

    while (this.holidaysRepo.findByIdHoliday(date) != null) {
         date = date.minusDays(1);
    }        

    // Check if order deadline passed based on given date, deadlineDays and deadlineTime (deadline)
    //return (date.toLocalDateTime(deadlineTime).compareTo(LocalDateTime.now()) < 0);

    // When we ll change deadline time to utc, use this: 
    //return date.toLocalDateTime(deadlineTime).toDateTime(DateTimeZone.UTC);
    return date.toLocalDateTime(deadlineTime).toDateTime(); // To default zone
}
项目:yum    文件:DailyMenusApiControllerTest.java   
@Test
public void testDailyMenusIdPut_400_DailyMenuEntity_BadRequest() throws Exception
{
    mockFoodList.add(mockFood2);
    mockDailyMenu.setFoods(mockFoodList);
    mockDailyMenuList.add(mockDailyMenu);

    LocalTime deadline = new LocalTime(0, 0);
    Settings sets = new Settings(1, deadline, null, "€", "notes", "tos", "policy", 0, 0, "", "");
    given(mockSettingsRepository.findOne(1)).willReturn(sets);

    given(mockDailyMenuRepository.findById(6)).willReturn(mockDailyMenu);
    //given(mockHolidaysRepository.findByIdHoliday(new LocalDate(2017,04,28))).willReturn(null);

    mockMvc.perform(put("/api/dailyMenus/{id}", "6")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content("{}")
    ).andExpect(status().isBadRequest())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8));

}
项目:sns-todo    文件:WechatController.java   
/**
 * 定义微信菜单
 */
@WxButton(group = WxButton.Group.RIGHT, main = true, name = "Hi")
public String right(WxUser wxUser) {
    log.info("wxUser:{}", wxUser);
    int hourOfDay = LocalTime.now().getHourOfDay();
    String wenhou;
    if (hourOfDay >= 7 && hourOfDay < 12) {
        wenhou = "上午好";
    } else if (hourOfDay == 12) {
        wenhou = "中午好";
    } else if (hourOfDay > 12 && hourOfDay < 19) {
        wenhou = "下午好";
    } else if (hourOfDay >= 19 && hourOfDay < 22) {
        wenhou = "晚上好";
    } else {
        wenhou = "太晚了。生活再忙,也要休息";
    }
    log.info("wenhou:{}", wenhou);
    return wxUser.getNickName() + "," + wenhou;
}
项目:Auto.js    文件:TimedTaskSettingActivity.java   
private void setUpTime() {
    mDisposableTaskDate.setText(DATE_FORMATTER.print(LocalDate.now()));
    mDisposableTaskTime.setText(TIME_FORMATTER.print(LocalTime.now()));
    if (mTimedTask == null) {
        mDailyTaskRadio.setChecked(true);
        return;
    }
    if (mTimedTask.isDisposable()) {
        mDisposableTaskRadio.setChecked(true);
        mDisposableTaskTime.setText(TIME_FORMATTER.print(mTimedTask.getMillis()));
        mDisposableTaskDate.setText(DATE_FORMATTER.print(mTimedTask.getMillis()));
        return;
    }
    LocalTime time = LocalTime.fromMillisOfDay(mTimedTask.getMillis());
    mDailyTaskTimePicker.setCurrentHour(time.getHourOfDay());
    mDailyTaskTimePicker.setCurrentMinute(time.getMinuteOfHour());
    if (mTimedTask.isDaily()) {
        mDailyTaskRadio.setChecked(true);
    } else {
        mWeeklyTaskRadio.setChecked(true);
        for (int i = 0; i < mDayOfWeekCheckBoxes.size(); i++) {
            mDayOfWeekCheckBoxes.get(i).setChecked(mTimedTask.hasDayOfWeek(i + 1));
        }
    }

}
项目:hyperrail-for-android    文件:StationActivity.java   
private void bind(Station station) {
    StationFacilities facilities = station.getStationFacilities();
    StringBuilder openingHoursString = new StringBuilder();
    for (int i = 0; i < 7; i++) {
        LocalTime[] openingHours = facilities.getOpeningHours(i);
        if (openingHours == null) {
            openingHoursString.append("Closed");
        } else {
            openingHoursString.append(openingHours[0].toString("HH:mm")).append(" - ").append(openingHours[1].toString("HH:mm")).append("\n");
        }
    }
    ((TextView) findViewById(R.id.text_hours)).setText(openingHoursString.toString());
    ((TextView) findViewById(R.id.text_station)).setText(station.getLocalizedName());
    ((TextView) findViewById(R.id.text_address)).setText(String.format("%s %s %s", facilities.getStreet(), facilities.getZip(), facilities.getCity()));

    findViewById(R.id.image_tram).setVisibility(facilities.hasTram() ? View.VISIBLE : View.GONE);
    findViewById(R.id.image_bus).setVisibility(facilities.hasBus() ? View.VISIBLE : View.GONE);
    findViewById(R.id.image_subway).setVisibility(facilities.hasMetro() ? View.VISIBLE : View.GONE);

    // TODO: display information on accessibility
}
项目:beanmother    文件:DateToJodaTimeBaseLocalConverterTest.java   
@Test
public void convert() throws Exception {
    String dateString = "06/27/2017 12:30";
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm");
    Date date = df.parse(dateString);

    LocalTime localTime = (LocalTime) converter.convert(date, TypeToken.of(LocalTime.class));
    assertEquals(12, localTime.getHourOfDay());
    assertEquals(30, localTime.getMinuteOfHour());

    LocalDate localDate = (LocalDate) converter.convert(date, TypeToken.of(LocalDate.class));
    assertEquals(2017, localDate.getYear());
    assertEquals(6, localDate.getMonthOfYear());
    assertEquals(27, localDate.getDayOfMonth());

    LocalDateTime localDateTime = (LocalDateTime) converter.convert(date, TypeToken.of(LocalDateTime.class));
    assertEquals(12, localDateTime.getHourOfDay());
    assertEquals(30, localDateTime.getMinuteOfHour());
    assertEquals(2017, localDateTime.getYear());
    assertEquals(6, localDateTime.getMonthOfYear());
    assertEquals(27, localDateTime.getDayOfMonth());
}
项目:beanmother    文件:StringToJodaTimeBaseLocalConverterTest.java   
@Test
public void convert() throws Exception {
    String dateString = "1985-09-03 13:30";

    LocalTime localTime = (LocalTime) converter.convert(dateString, TypeToken.of(LocalTime.class));
    assertEquals(13, localTime.getHourOfDay());
    assertEquals(30, localTime.getMinuteOfHour());

    LocalDate localDate = (LocalDate) converter.convert(dateString, TypeToken.of(LocalDate.class));
    assertEquals(1985, localDate.getYear());
    assertEquals(9, localDate.getMonthOfYear());
    assertEquals(3, localDate.getDayOfMonth());

    LocalDateTime localDateTime = (LocalDateTime) converter.convert(dateString, TypeToken.of(LocalDateTime.class));
    assertEquals(13, localDateTime.getHourOfDay());
    assertEquals(30, localDateTime.getMinuteOfHour());
    assertEquals(1985, localDateTime.getYear());
    assertEquals(9, localDateTime.getMonthOfYear());
    assertEquals(3, localDateTime.getDayOfMonth());
}
项目:Mutters    文件:TestTimeSlot.java   
@Test
public void testBasicMatch()
{
  TemplatedUtterance utterance = new TemplatedUtterance(tokenizer.tokenize("at {time}"));

  String[] input = tokenizer.tokenize("at 6:45am");
  Slots slots = new Slots();
  Context context = new Context();

  TimeSlot slot = new TimeSlot("time");
  slots.add(slot);

  TemplatedUtteranceMatch match = utterance.matches(input, slots, context);

  assertThat(match, is(notNullValue()));
  assertThat(match.isMatched(), is(true));
  assertThat(match.getSlotMatches().size(), is(1));

  SlotMatch slotMatch = match.getSlotMatches().get(slot);
  assertThat(slotMatch, is(notNullValue()));
  assertThat(slotMatch.getOrginalValue(), is("6:45am"));
  assertThat(slotMatch.getValue(), is(new LocalTime(6, 45)));
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test
public void sumDeHours()
{
    // Fixture Setup
    final LocalTime Hour1 = new LocalTime( 1, 12, 25 );
    final LocalTime Hour2 = new LocalTime( 2, 12, 25 );
    final LocalTime HourEsperada = new LocalTime( 3, 12, 25 );

    // Exercise SUT
    final int novaHour = Hour1.getHourOfDay() + Hour2.getHourOfDay();

    // Result Verification
    Assert.assertEquals( novaHour, HourEsperada.getHourOfDay() );

    // Fixture Teardown
}
项目:oma-riista-web    文件:MooseDataCardExtractor.java   
/**
 * Converts given date and duration into a legal hunting day interval. Duration is rounded down
 * to half an hour resolution and, if needed, replaced with a legal default value in case a
 * value out of acceptable range is provided.
 */
@Nonnull
public static Interval getHuntingDayInterval(
        @Nonnull final LocalDate date, @Nullable final Float huntingDurationInHours) {

    Objects.requireNonNull(date, "date is null");

    final Float legalizedDuration = Optional.ofNullable(huntingDurationInHours)
            .filter(MooseDataCardHuntingDayField.HUNTING_DAY_DURATION::isValueInRange)
            .orElseGet(() -> Integer.valueOf(DEFAULT_DURATION).floatValue());

    final double durationRoundedDownToNearestHalfHour = roundDownToNearestHalfHour(legalizedDuration.doubleValue());
    final double durationRoundedToNearestHour = Math.ceil(durationRoundedDownToNearestHalfHour);

    final DateTime startTime = defaultStartTimeMustBeAdvanced(durationRoundedDownToNearestHalfHour)
            ? date.toDateTime(new LocalTime(
                    (int) (48.0 - durationRoundedToNearestHour),
                    (int) ((durationRoundedToNearestHour - durationRoundedDownToNearestHalfHour) * 60.0)))
            : date.toDateTime(DEFAULT_HUNTING_DAY_START_TIME);

    return new Interval(
            startTime.withZone(Constants.DEFAULT_TIMEZONE),
            startTime.plusMinutes((int) (durationRoundedDownToNearestHalfHour * 60.0))
                    .withZone(Constants.DEFAULT_TIMEZONE));
}
项目:db-fahrplan-api    文件:ApiClientMapperTest.java   
@Test
public void parsesJourneyDetails() throws IOException {
    try (InputStream is = getClass().getResourceAsStream("journeyDetails.json")) {
        JourneyDetailResponse response = sut.readValue(is, JourneyDetailResponse.class);
        Assert.assertEquals(6, response.getJourneyDetail().getStops().getStop().size());
        Assert.assertEquals(1, response.getJourneyDetail().getNames().getName().size());
        Assert.assertEquals(1, response.getJourneyDetail().getTypes().getType().size());
        Assert.assertEquals(1, response.getJourneyDetail().getOperators().getOperator().size());
        Assert.assertEquals(1, response.getJourneyDetail().getNotes().getNote().size());
        final Stop stop = response.getJourneyDetail().getStops().getStop().get(0);
        Assert.assertEquals("Frankfurt(Main)Hbf", stop.getName());
        Assert.assertEquals("8000105", stop.getId());
        Assert.assertEquals(8.663785, stop.getLon(), 0.000001);
        Assert.assertEquals(50.107149, stop.getLat(), 0.000001);
        Assert.assertEquals(LocalTime.parse("15:02"), stop.getDepTime());
        Assert.assertEquals(LocalDate.parse("2016-02-22"), stop.getDepDate());
        Assert.assertEquals(0, stop.getRouteIdx().intValue());
        Assert.assertEquals("13", stop.getTrack());
    }
}
项目:oma-riista-web    文件:GroupHuntingDayCrudFeatureTest.java   
private static GroupHuntingDayDTO createHuntingDayDTO(final HuntingClubGroup group, final boolean withHounds) {
    final GroupHuntingDayDTO dto = new GroupHuntingDayDTO();
    dto.setHuntingGroupId(group.getId());

    dto.setStartDate(today());
    dto.setEndDate(today());

    dto.setStartTime(LocalTime.now());
    dto.setEndTime(LocalTime.now().plusHours(1));

    dto.setBreakDurationInMinutes(10);
    dto.setNumberOfHunters(1);

    dto.setHuntingMethod(getAnyHuntingMethodByHounds(withHounds));
    return dto;
}
项目:oma-riista-web    文件:GameDiaryFeatureTest.java   
@Test(expected = HarvestPermitSpeciesAmountNotFound.class)
public void testUpdateHarvest_whenSpeciesIsNotValid() {
    withPerson(author -> {
        final GameSpecies species = model().newGameSpecies(true);
        final Harvest harvest = model().newHarvest(species, author);
        final HarvestPermit permit = model().newHarvestPermit(true);
        final HarvestPermitSpeciesAmount amount = model().newHarvestPermitSpeciesAmount(permit, species);
        model().newHarvestReportFields(species, true);

        onSavedAndAuthenticated(createUser(author), () -> {

            invokeUpdateHarvest(create(harvest, 5)
                    .mutate()
                    .withPermitNumber(permit.getPermitNumber())
                    .withPointOfTime(amount.getBeginDate().minusDays(1).toLocalDateTime(LocalTime.MIDNIGHT))
                    .build());
        });
    });
}
项目:Mutters    文件:TestTimeSlot.java   
@Test
public void testMatchWithTimeZone()
{
  TemplatedUtterance utterance = new TemplatedUtterance(tokenizer.tokenize("at {time}"));

  String[] input = tokenizer.tokenize("at 6:45am");
  Slots slots = new Slots();
  Context context = new Context();
  context.setTimeZone(TimeZone.getTimeZone("Africa/Johannesburg"));

  TimeSlot slot = new TimeSlot("time");
  slots.add(slot);

  TemplatedUtteranceMatch match = utterance.matches(input, slots, context);

  assertThat(match, is(notNullValue()));
  assertThat(match.isMatched(), is(true));
  assertThat(match.getSlotMatches().size(), is(1));

  SlotMatch slotMatch = match.getSlotMatches().get(slot);
  assertThat(slotMatch, is(notNullValue()));
  assertThat(slotMatch.getOrginalValue(), is("6:45am"));
  assertThat(slotMatch.getValue(), is(new LocalTime(6, 45)));
}
项目:integrations    文件:FormattedDateTime.java   
private void formatTime( String time, String timePattern ) {
    DateTimeFormatter customTimeFormatter = DateTimeFormat.forPattern( timePattern );
    String timeString = time;
    if ( time != null ) {
        timeString = time;
        // timeString should already be padded with zeros before being parsed
        myTime = time == null ? null : LocalTime.parse( timeString, customTimeFormatter );
        dt = dt.withTime( myTime.getHourOfDay(), myTime.getMinuteOfHour(), 0, 0 );
    }
}
项目:integrations    文件:FormattedDateTime.java   
private void formatTime( String time, String timePattern ) {
    DateTimeFormatter customTimeFormatter = DateTimeFormat.forPattern( timePattern );
    String timeString = time;
    if ( time != null ) {
        timeString = time;
        // timeString should already be padded with zeros before being parsed
        myTime = time == null ? null : LocalTime.parse( timeString, customTimeFormatter );
        dt = dt.withTime( myTime.getHourOfDay(), myTime.getMinuteOfHour(), 0, 0 );
    }
}
项目:integrations    文件:FormattedDateTime.java   
private void formatTime( String time, String timePattern ) {
    DateTimeFormatter customTimeFormatter = DateTimeFormat.forPattern( timePattern );
    String timeString = time;
    if ( time != null && !time.equals( "" ) ) {
        timeString = time;
        // timeString should already be padded with zeros before being parsed
        myTime = time == null ? null : LocalTime.parse( timeString, customTimeFormatter );
        dt = dt.withTime( myTime.getHourOfDay(), myTime.getMinuteOfHour(), 0, 0 );
    }
}
项目:integrations    文件:FormattedDateTime.java   
private void formatTime( String time, String timePattern ) {
    DateTimeFormatter customTimeFormatter = DateTimeFormat.forPattern( timePattern );
    String timeString = time;
    if ( time != null ) {
        timeString = time;
        // timeString should already be padded with zeros before being parsed
        myTime = time == null ? null : LocalTime.parse( timeString, customTimeFormatter );
        dt = dt.withTime( myTime.getHourOfDay(), myTime.getMinuteOfHour(), 0, 0 );
    }
}
项目:GitHub    文件:FormatRule.java   
private Class<?> getTimeOnlyType() {
    String type=ruleFactory.getGenerationConfig().getTimeType();
    if (!isEmpty(type)){
        try {
            Class<?> clazz=Thread.currentThread().getContextClassLoader().loadClass(type);
            return clazz;
        }
        catch (ClassNotFoundException e) {
            throw new GenerationException(format("could not load java type %s for time format", type), e);
        }
    }
    return ruleFactory.getGenerationConfig().isUseJodaLocalTimes() ? LocalTime.class : String.class;
}
项目:GitHub    文件:FormatRuleJodaTest.java   
@Parameters
public static Collection<Object[]> data() {
    return asList(new Object[][] {
            { "date-time", DateTime.class },
            { "date", LocalDate.class },
            { "time", LocalTime.class }});
}
项目:GitHub    文件:JodaDatesIT.java   
@Test
public void useJodaLocalTimesCausesLocalTimeDefaultValues() throws ClassNotFoundException, IntrospectionException,
        InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, InvocationTargetException {
    ClassLoader classLoader = schemaRule.generateAndCompile("/schema/default/default.json", "com.example",
            config("useJodaLocalTimes", true));

    Class<?> classWithDefaults = classLoader.loadClass("com.example.Default");

    Object instance = classWithDefaults.newInstance();

    Method getter = classWithDefaults.getMethod("getTimeAsStringWithDefault");

    assertThat((LocalTime) getter.invoke(instance), is(equalTo(new LocalTime("16:15:00"))));
}
项目:justintrain-client-android    文件:Train.java   
public Train(Journey.Solution s) {
        this.trainCategory = s.getTrainCategory();
        this.trainId = s.getTrainId();
//        this.trainDepartureStationId = s.getTrainDepartureStationId();
        this.trainDepartureStationName = s.getDepartureStationName();
        this.trainArrivalStationId = s.getArrivalStationId();
        this.trainArrivalStationName = s.getArrivalStationName();
        this.timeDifference = s.getTimeDifference();
        this.progress = s.getProgress();
        this.stops = new LinkedList<>();
        this.trainStatusCode = -1;
        this.timeDifference = 0;
        this.isDeparted = false;
        Stop departure = new Stop();
        departure.stationName = s.getDepartureStationName().toUpperCase();
        departure.plannedDepartureTime = DateTime.now().withTime(LocalTime.parse(s.getDepartureTimeReadable()));
        departure.isVisited = false;
        departure.currentStopTypeCode = 1;
        departure.currentStopStatusCode = 0;
        Stop arrival = new Stop();
        arrival.stationName = s.getArrivalStationName().toUpperCase();
        arrival.plannedDepartureTime = DateTime.now().withTime(LocalTime.parse(s.getArrivalTimeReadable()));
        arrival.isVisited = false;
        arrival.currentStopTypeCode = 3;
        arrival.currentStopStatusCode = 0;
        this.stops.add(departure);
        this.stops.add(arrival);
    }
项目:justintrain-client-android    文件:Train.java   
public Train(Journey.Solution.Change s) {
        this.trainCategory = s.getTrainCategory();
        this.trainId = s.getTrainId();
//        this.trainDepartureStationId = s.getTrainDepartureStationId();
        this.trainDepartureStationName = s.getDepartureStationName();
        this.trainArrivalStationId = s.getArrivalStationId();
        this.trainArrivalStationName = s.getArrivalStationName();
        this.timeDifference = s.getTimeDifference();
        this.progress = s.getProgress();
        this.stops = new LinkedList<>();
        this.trainStatusCode = -1;
        this.timeDifference = 0;
        this.isDeparted = false;
        Stop departure = new Stop();
        departure.stationName = s.getDepartureStationName().toUpperCase();
        departure.plannedDepartureTime = DateTime.now().withTime(LocalTime.parse(s.getDepartureTimeReadable()));
        departure.isVisited = false;
        departure.currentStopTypeCode = 1;
        departure.currentStopStatusCode = 0;
        Stop arrival = new Stop();
        arrival.stationName = s.getArrivalStationName() != null ? s.getArrivalStationName().toUpperCase() : "";
        arrival.plannedDepartureTime = DateTime.now().withTime(LocalTime.parse(s.getArrivalTimeReadable()));
        arrival.isVisited = false;
        arrival.currentStopTypeCode = 3;
        arrival.currentStopStatusCode = 0;
        this.stops.add(departure);
        this.stops.add(arrival);
//        this.lastSeenStationName = s.getSeenStationName();
//        this.lastSeenTimeReadable = s.getLastSeenTimeReadable();
//        this.cancelledStopsInfo = s.getCancelledStopsInfo();
//        this.firstClassOrientationCode = s.getFirstClassOrientationCode();
//        this.trainStatusCode = s.getTrainStatusCode();
//        this.isDeparted = s.isDeparted();
//        this.isArrivedToDestination = s.isArrivedToDestination();
    }
项目:yum    文件:User.java   
public boolean hasNonFinalOrders(LocalTime deadlineTime, int deadlineDays) {
    if (dailyOrders == null) {
        return false;
    } else {
        for (DailyOrder dailyOrder : dailyOrders) {
            if (!dailyOrder.isFinalised(deadlineTime, deadlineDays)) {
                return true;
            }
        }
        return false;
    }
}
项目:yum    文件:User.java   
public boolean hasFinalOrders(LocalTime deadlineTime, int deadlineDays) {
    if (dailyOrders == null) {
        return false;
    } else {
        for (DailyOrder dailyOrder : dailyOrders) {
            if (dailyOrder.isFinalised(deadlineTime, deadlineDays)) {
                return true;
            }
        }
        return false;
    }
}
项目:yum    文件:User.java   
public int getUsersOrdersStatus(LocalTime deadlineTime, int deadlineDays){
    //Check if user haven't orders.
    if (this.getDailyOrders().isEmpty()) {return 0;} 
    //Check if user orders is Final or not.
    if (this.hasFinalOrders(deadlineTime, deadlineDays) && this.hasNonFinalOrders(deadlineTime,deadlineDays)) {
        return 2;
    } else if (this.hasFinalOrders(deadlineTime,deadlineDays)) {
        return 1;
    } else {
        return 3;
    }
}
项目:yum    文件:Settings.java   
public Settings(int id, LocalTime deadline, DateTime lastEdit, String currency, String notes, String tos, String policy, int version, int foods_version, String reportEmail, String workingDays) {
    this.id = id;
    this.deadline = deadline;
    this.lastEdit = lastEdit;
    this.currency = currency;
    this.notes = notes;
    this.tos = tos;
    this.policy = policy;
    this.version = version;
    this.foods_version = foods_version;
    this.reportEmail = reportEmail;
    this.workingDays = workingDays;
}
项目:yum    文件:GlobalsettingsService.java   
private boolean oldDeadlinePassed(LocalDate date, int deadlineDays, LocalTime deadlineTime) {
    // Check if order deadline passed based on given date, deadlineDays and deadlineTime (deadline)
    date = date.minusDays(deadlineDays);
    while (this.holidaysRepo.findByIdHoliday(date) != null) {
         date = date.minusDays(1);
    }  
    return (date.toLocalDateTime(deadlineTime).compareTo(LocalDateTime.now()) < 0);
}
项目:yum    文件:DailyMenuService.java   
public boolean deadlinePassed(LocalDate date) {
    Settings settings = settingsRepo.findOne(1);
    int deadlineDays = settings.getDeadlineDays();
    LocalTime deadlineTime = settings.getDeadline();

    date = date.minusDays(deadlineDays);

    while (this.holidaysRepo.findByIdHoliday(date) != null) {
         date = date.minusDays(1);
    }        

    // Check if order deadline passed based on given date, deadlineDays and deadlineTime (deadline)
    return (date.toLocalDateTime(deadlineTime).compareTo(LocalDateTime.now()) < 0);
}
项目:yum    文件:OrdersService.java   
public boolean deadlinePassed(LocalDate date) {
    Settings settings = settingsRep.findOne(1);
    int deadlineDays = settings.getDeadlineDays();
    LocalTime deadlineTime = settings.getDeadline();

    date = date.minusDays(deadlineDays);

    while (this.holidaysRepo.findByIdHoliday(date) != null) {
        date = date.minusDays(1);
    }

    // Check if order deadline passed based on given date, deadlineDays and deadlineTime (deadline)
    return (date.toLocalDateTime(deadlineTime).compareTo(LocalDateTime.now()) < 0);
}
项目:yum    文件:UsersService.java   
public boolean deadlinePassed(LocalDate date) {
    Settings settings = settingsRepo.findOne(1);
    int deadlineDays = settings.getDeadlineDays();
    LocalTime deadlineTime = settings.getDeadline();

    date = date.minusDays(deadlineDays);

    while (this.holidaysRepo.findByIdHoliday(date) != null) {
        date = date.minusDays(1);
    }

    // Check if order deadline passed based on given date, deadlineDays and deadlineTime (deadline)
    return (date.toLocalDateTime(deadlineTime).compareTo(LocalDateTime.now()) < 0);
}
项目:yum    文件:DailyMenusApiControllerTest.java   
@BeforeClass
public static void initMock()
{
    mockDailyMenuList = new ArrayList<>();
    mockFoodList = new ArrayList<>();
    mockOrderItemsList = new ArrayList<>();

    mockFood1 = new Food(1);
    mockFood1.setName("mousaka");
    mockFood1.setFoodType(FoodType.MAIN);
    mockFood1.setDescription("tradition main dish");
    mockFood1.setPrice(new BigDecimal("5.5"));
    mockFood1.setArchived(false);
    mockFood1.setLastEdit(new DateTime(2017, 4, 28, 13, 5));
    mockFood1.setVersion(1);

    mockFood2 = new Food(2);
    mockFood2.setName("greek salad");
    mockFood2.setFoodType(FoodType.SALAD);
    mockFood2.setDescription("tradition cretan salad");
    mockFood2.setPrice(new BigDecimal("4"));
    mockFood2.setArchived(false);
    mockFood2.setLastEdit(new DateTime(2017, 4, 28, 13, 30));
    mockFood2.setVersion(1);

    mockDailyMenu = new DailyMenu();
    mockDailyMenu.setId(6);
    mockDailyMenu.setDate(new LocalDate(2117, 9, 1));
    mockDailyMenu.setLastEdit(new DateTime(2017, 4, 28, 14, 00));
    mockDailyMenu.setVersion(1);

    mockSettings = new Settings(1);
    mockSettings.setCurrency("EURO");
    mockSettings.setDeadline(new LocalTime(12, 0, 0));
    mockSettings.setNotes("Notes..");
    mockSettings.setPolicy("Policy..");
    mockSettings.setTos("Tos..");
    mockSettings.setVersion(1);

}
项目:yum    文件:FoodsApiControllerTest.java   
@Test
@WithMockAuth(id="1")
public void testFoodsPutOk() throws Exception {
    Food mockFoodOk = new Food(10, "Pastitsio", new ArrayList<>(), FoodType.MAIN, "test Pastitsio", new BigDecimal("5.65"), false, newLastEdit("01/01/2017 00:00:00"), false);

    Settings global_settings = new Settings(1, LocalTime.MIDNIGHT,  DateTime.now(), "", "", "", "", 0, 1,"","");

    given(mockFoodRepository.findById(10)).willReturn(mockFoodOk);
    given(settingsRepo.findOne(1)).willReturn(global_settings);

    mockMvc.perform(put("/api/foods/{id}",10).content(
    "{\n" +
    "  \"foodName\": \"string\",\n" +
    "  \"foodType\": \"Drink\",\n" +
    "  \"description\": \"string\",\n" +
    "  \"price\": 10,\n" +
    "  \"standard\": \"false\",\n" +
    "  \"lastEdit\": {\n" +
    "    \"timeStamp\": \"2017-01-01T00:00:00.000Z\"\n" +
    "  }\n" +
    "}"
    ).contentType(MediaType.APPLICATION_JSON_UTF8))
        .andExpect(status().isNoContent())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8));


    verify(mockFoodRepository, times(1)).findById(10);
    assertEquals(mockFoodOk, mockFoodRepository.findById(10) );
}
项目:yum    文件:FoodsApiControllerTest.java   
@Test
@WithMockAuth(id="1")
public void testFoodsPostOk() throws Exception {

    Food mockFoodOk = new Food(0, "Pastitsio", new ArrayList<>(), FoodType.MAIN, "test Pastitsio", new BigDecimal("5.65"), false, null, true);         
    Settings global_settings = new Settings(1, LocalTime.MIDNIGHT,  DateTime.now(), "", "", "", "", 0, 1, "", "");


    given(settingsRepo.findOne(1)).willReturn(global_settings); 
    given(mockFoodRepository.findByNameAndArchived(mockFoodOk.getName(), false)).willReturn(null);

    mockMvc.perform(post("/api/foods").content(
    "{\n" +
    "  \"foodName\": \""+mockFoodOk.getName()+"\",\n" +
    "  \"foodType\": \""+foodType.convertToDatabaseColumn(mockFoodOk.getFoodType())+"\",\n" +
    "  \"description\": \""+mockFoodOk.getDescription()+"\",\n" +
    "  \"standard\": \""+mockFoodOk.isStandard()+"\",\n" +
    "  \"price\": "+mockFoodOk.getPrice()+"\n" +

    "}"
    ).contentType(MediaType.APPLICATION_JSON_UTF8))
        .andExpect(status().isNoContent());


    verify(mockFoodRepository, times(1)).findByNameAndArchived(mockFoodOk.getName(), false);
    verify(mockFoodRepository, times(1)).save(mockFoodOk);
    verifyNoMoreInteractions(mockFoodRepository);

}
项目:yum    文件:GlobalsettingsApiControllerTest.java   
@BeforeClass
public static void initMock()
{
    mockSettings = new Settings(1);

    mockSettings.setCurrency("Euro");
    mockSettings.setDeadline(new LocalTime(12, 59, 59));
    mockSettings.setLastEdit(new DateTime(2017, 5, 26, 18, 0));
    mockSettings.setNotes("Some notes");
    mockSettings.setPolicy("Some policy");
    mockSettings.setTos("Some terms of service");
    mockSettings.setVersion(0);
}
项目:WeiMusicCommunity-server    文件:JodaTimeTypeHoldler.java   
protected LocalTime toLocalTime(final Time time) {
    if (time == null) {
        return null;
    } else {
        return newLocalTime(time);
    }
}
项目:Auto.js    文件:TimedTask.java   
public long getNextTime() {
    if (isDisposable()) {
        return mMillis;
    }
    if (isDaily()) {
        LocalTime time = LocalTime.fromMillisOfDay(mMillis);
        long nextTimeMillis = time.toDateTimeToday().getMillis();
        if (System.currentTimeMillis() > nextTimeMillis) {
            return nextTimeMillis + TimeUnit.DAYS.toMillis(1);
        }
        return nextTimeMillis;
    }
    return getNextTimeOfWeeklyTask();

}
项目:Auto.js    文件:TimedTask.java   
private long getNextTimeOfWeeklyTask() {
    int dayOfWeek = DateTime.now().getDayOfWeek();
    long nextTimeMillis = LocalTime.fromMillisOfDay(mMillis).toDateTimeToday().getMillis();
    for (int i = 0; i < 8; i++) {
        if ((getDayOfWeekTimeFlag(dayOfWeek) & mTimeFlag) != 0) {
            if (System.currentTimeMillis() <= nextTimeMillis) {
                return nextTimeMillis;
            }
        }
        dayOfWeek++;
        nextTimeMillis += TimeUnit.DAYS.toMillis(1);
    }
    throw new IllegalStateException("Should not happen! timeFlag = " + mTimeFlag + ", dayOfWeek = " + DateTime.now().getDayOfWeek());
}
项目:Auto.js    文件:TimedTaskSettingActivity.java   
@Click(R.id.disposable_task_time_container)
void showDisposableTaskTimePicker() {
    LocalTime time = TIME_FORMATTER.parseLocalTime(mDisposableTaskTime.getText().toString());
    new TimePickerDialog(this, (view, hourOfDay, minute) -> mDisposableTaskTime.setText(TIME_FORMATTER.print(new LocalTime(hourOfDay, minute))), time.getHourOfDay(), time.getMinuteOfHour(), true)
            .show();

}