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


Java LocalTime类代码示例

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


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

示例1: TIME

import org.joda.time.LocalTime; //导入依赖的package包/类
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()); 
		}			
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:24,代码来源:DateTimeFunctions.java

示例2: getDeadline

import org.joda.time.LocalTime; //导入依赖的package包/类
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
}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:19,代码来源:MenusService.java

示例3: testDailyMenusIdPut_400_DailyMenuEntity_BadRequest

import org.joda.time.LocalTime; //导入依赖的package包/类
@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));

}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:22,代码来源:DailyMenusApiControllerTest.java

示例4: right

import org.joda.time.LocalTime; //导入依赖的package包/类
/**
 * 定义微信菜单
 */
@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;
}
 
开发者ID:helloworldtang,项目名称:sns-todo,代码行数:23,代码来源:WechatController.java

示例5: setUpTime

import org.joda.time.LocalTime; //导入依赖的package包/类
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));
        }
    }

}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:27,代码来源:TimedTaskSettingActivity.java

示例6: createDisposableTask

import org.joda.time.LocalTime; //导入依赖的package包/类
private TimedTask createDisposableTask() {
    LocalTime time = TIME_FORMATTER.parseLocalTime(mDisposableTaskTime.getText().toString());
    LocalDate date = DATE_FORMATTER.parseLocalDate(mDisposableTaskDate.getText().toString());
    LocalDateTime dateTime = new LocalDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
            time.getHourOfDay(), time.getMinuteOfHour());
    if (dateTime.isBefore(LocalDateTime.now())) {
        Toast.makeText(this, R.string.text_disposable_task_time_before_now, Toast.LENGTH_SHORT).show();
        return null;
    }
    return TimedTask.disposableTask(dateTime, mScriptFile.getPath(), ExecutionConfig.getDefault());
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:12,代码来源:TimedTaskSettingActivity.java

示例7: bind

import org.joda.time.LocalTime; //导入依赖的package包/类
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
}
 
开发者ID:hyperrail,项目名称:hyperrail-for-android,代码行数:22,代码来源:StationActivity.java

示例8: convert

import org.joda.time.LocalTime; //导入依赖的package包/类
@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());
}
 
开发者ID:keepcosmos,项目名称:beanmother,代码行数:23,代码来源:DateToJodaTimeBaseLocalConverterTest.java

示例9: convert

import org.joda.time.LocalTime; //导入依赖的package包/类
@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());
}
 
开发者ID:keepcosmos,项目名称:beanmother,代码行数:21,代码来源:StringToJodaTimeBaseLocalConverterTest.java

示例10: testBasicMatch

import org.joda.time.LocalTime; //导入依赖的package包/类
@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)));
}
 
开发者ID:rabidgremlin,项目名称:Mutters,代码行数:24,代码来源:TestTimeSlot.java

示例11: sumDeHours

import org.joda.time.LocalTime; //导入依赖的package包/类
@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
}
 
开发者ID:evandrocoan,项目名称:ComputerScienceGraduation,代码行数:17,代码来源:FirstClassJunitIndroduction.java

示例12: getHuntingDayInterval

import org.joda.time.LocalTime; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:30,代码来源:MooseDataCardExtractor.java

示例13: parsesJourneyDetails

import org.joda.time.LocalTime; //导入依赖的package包/类
@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());
	}
}
 
开发者ID:highsource,项目名称:db-fahrplan-api,代码行数:21,代码来源:ApiClientMapperTest.java

示例14: createHuntingDayDTO

import org.joda.time.LocalTime; //导入依赖的package包/类
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;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:17,代码来源:GroupHuntingDayCrudFeatureTest.java

示例15: testUpdateHarvest_whenSpeciesIsNotValid

import org.joda.time.LocalTime; //导入依赖的package包/类
@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());
        });
    });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:20,代码来源:GameDiaryFeatureTest.java


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