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


Java DateTimeFormat类代码示例

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


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

示例1: adminAddRentHouseDeal

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@RequestMapping(value="adminAddRentHouseDeal.do", method={RequestMethod.GET,RequestMethod.POST})
public ModelAndView adminAddRentHouseDeal(@RequestParam(value ="inputTime") @DateTimeFormat(pattern="yyyy-MM-dd") Date date,HttpServletRequest request, RentHouseDeal rentHouseDeal) {
	ModelAndView modelAndView = new ModelAndView();
	HttpSession session = request.getSession();
	rentHouseDeal.setRentTime(date);
	
	System.err.println("ctbb");
	System.err.println(date);
	System.err.println(rentHouseDeal.getRentHouseDay());
	System.err.println(rentHouseDeal.getRentTime());
	
	rentHouseDealDao.insertRentHouseDeal(rentHouseDeal);
	
	List<RentHouseDeal> rentHouseDealList = rentHouseDealDao.selectAll();
	session.setAttribute("rentHouseDealList", rentHouseDealList);
	
	modelAndView.setViewName("SystemUser/managerRentHistory");
	return modelAndView;
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:20,代码来源:AdminRentController.java

示例2: events

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@GetMapping("events")
HttpEntity<Resources<?>> events(PagedResourcesAssembler<AbstractEvent<?>> assembler,
		@SortDefault("publicationDate") Pageable pageable,
		@RequestParam(required = false) @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime since,
		@RequestParam(required = false) String type) {

	QAbstractEvent $ = QAbstractEvent.abstractEvent;

	BooleanBuilder builder = new BooleanBuilder();

	// Apply date
	Optional.ofNullable(since).ifPresent(it -> builder.and($.publicationDate.after(it)));

	// Apply type
	Optional.ofNullable(type) //
			.flatMap(events::findEventTypeByName) //
			.ifPresent(it -> builder.and($.instanceOf(it)));

	Page<AbstractEvent<?>> result = events.findAll(builder, pageable);

	PagedResources<Resource<AbstractEvent<?>>> resource = assembler.toResource(result, event -> toResource(event));
	resource
			.add(links.linkTo(methodOn(EventController.class).events(assembler, pageable, since, type)).withRel("events"));

	return ResponseEntity.ok(resource);
}
 
开发者ID:olivergierke,项目名称:sos,代码行数:27,代码来源:EventController.java

示例3: diaryEntries

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@CacheControl(policy = CachePolicy.NO_CACHE)
@RequestMapping(method = RequestMethod.GET)
public List<GameDiaryEntryDTO> diaryEntries(
        @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) final LocalDate beginDate,
        @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) final LocalDate endDate,
        @RequestParam(required = false) final Boolean reportedForOthers,
        @RequestParam(required = false) final Boolean srvaEvents) {

    final Interval interval = beginDate.isAfter(endDate)
            ? DateUtil.createDateInterval(endDate, beginDate)
            : DateUtil.createDateInterval(beginDate, endDate);

    final List<GameDiaryEntryDTO> dtos = diaryFeature.listDiaryEntriesForActiveUser(
            interval, BooleanUtils.isTrue(reportedForOthers));

    if (BooleanUtils.isTrue(srvaEvents)) {
        dtos.addAll(srvaCrudFeature.listSrvaEventsForActiveUser(interval));
    }

    return dtos;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:22,代码来源:GameDiaryApiResource.java

示例4: postFlight

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
/**
 * Save / Update a given flight identified by the parameter flightId.<br/>
 * This method can be accessed via. HTTP using the POST method and the URL 
 * specified in the @RequestMapping's path parameter. 
 * The following parameters can be submitted with the HTTP Request:
 * @param flightId Unique identifier of a flight.
 * @param destination The destination where the flight is headed to.
 * @param origin The origin where the flight leaves.
 * @param destinationGate The gate identifier at the destination airport.
 * @param originGate The gate identifier at the origin airport.
 * @param startDate The date and time of the departure.
 * @param endDate The date and time of the arrival.
 * @return "OK" if save was successful.
 */
@RequestMapping(path = "api/flight", method = RequestMethod.POST)
public String postFlight(@RequestParam (value="flightId") String flightId, 
		@RequestParam(value="destination") String destination, 
		@RequestParam(value="origin") String origin, 
		@RequestParam(value="destinationGate", required=false) String destinationGate,
		@RequestParam(value="originGate", required=false) String originGate,
		@RequestParam(value="startDate") @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm") Date startDate,
		@RequestParam(value="endDate") @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm") Date endDate){
	// Just print the flightId to see something in the log.
	System.out.println(flightId);
	// Create a new Entity and map all request parameters to their destination:
	FlightEntity flightEntity = new FlightEntity();
	flightEntity.setFlightId(flightId);
	flightEntity.setDestination(destination);
	flightEntity.setOrigin(origin);
	flightEntity.setDestinationGate(destinationGate);
	flightEntity.setOriginGate(originGate);
	flightEntity.setStartDate(startDate);
	flightEntity.setEndDate(endDate);
	// Save the entity to the database, 
	// this will overwrite an existing entity with the same flightId.
	flightRepo.save(flightEntity);
	return "OK";
}
 
开发者ID:cr0wned0ne,项目名称:eflightservice-wi20162,代码行数:39,代码来源:RestFlightController.java

示例5: adminAddRentHouse

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@RequestMapping(value="adminAddRentHouse.do", method={RequestMethod.GET,RequestMethod.POST})
public ModelAndView adminAddRentHouse(@RequestParam(value ="inputPublishTime1") @DateTimeFormat(pattern="yyyy-MM-dd") Date inputPublishTime,HttpServletRequest request, RentHouse rentHouse) {
	
	ModelAndView modelAndView = new ModelAndView();
	HttpSession session = request.getSession();
	
	//设置表单时间
	rentHouse.setRentHousePublishTime(inputPublishTime);
	System.err.println(inputPublishTime);
	
	rentHouseDao.insertRentHouse(rentHouse);
	
	List<RentHouse> rentHouseList = rentHouseDao.selectAllRentHouse();
	session.setAttribute("rentHouseList", rentHouseList);
	
	modelAndView.setViewName("SystemUser/managerRent");
	return modelAndView;
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:19,代码来源:AdminRentController.java

示例6: adminAddBuilding

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@RequestMapping(value = "adminAddBuilding.do", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView adminAddBuilding(@RequestParam(value ="inputAddbuildingTimeHanded") @DateTimeFormat(pattern="yyyy-MM-dd") Date date,HttpServletRequest request, BuildingInfo buildingInfo) throws IllegalStateException, IOException {
	ModelAndView modelAndView = new ModelAndView();
	HttpSession session = request.getSession();

	//将时间设置进表单中
	buildingInfo.setBuildingTimeHanded(date);
	buildingInfoDao.insertBuildingInfo(buildingInfo);
	
	//重新获取楼盘列表
	List<BuildingInfo> buildingInfoList = buildingInfoDao.selectAll();
	session.setAttribute("buildingInfoList", buildingInfoList);
	
	modelAndView.setViewName("SystemUser/managerBuilding");
	return modelAndView;
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:17,代码来源:adminBuildingController.java

示例7: adminAddBuildingDeal

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@RequestMapping(value = "adminAddBuildingDeal.do", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView adminAddBuildingDeal(@RequestParam(value ="addDealtime") @DateTimeFormat(pattern="yyyy-MM-dd") Date date,HttpServletRequest request, BuildingDeal buildingDeal) throws IllegalStateException, IOException {
	ModelAndView modelAndView = new ModelAndView();
	HttpSession session = request.getSession();
	
	//设置表单时间
	buildingDeal.setBuildingDealTime(date);
	buildingDealDao.insertBuildingDeal(buildingDeal);
	
	//更新楼盘信息列表
	List<BuildingDeal> buildingDealList = buildingDealDao.selectAll();
	session.setAttribute("buildingDealList", buildingDealList);
	
	modelAndView.setViewName("SystemUser/managerBuildingHistory");
	return modelAndView;
}
 
开发者ID:632team,项目名称:EasyHousing,代码行数:17,代码来源:adminBuildingController.java

示例8: createConsumer

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@Transactional
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@RequestMapping(value = "/consumers", method = RequestMethod.POST)
public ConsumerToken createConsumer(@RequestBody Consumer consumer,
                                    @RequestParam(value = "expires", required = false)
                                    @DateTimeFormat(pattern = "yyyyMMddHHmmss") Date
                                        expires) {

  if (StringUtils.isContainEmpty(consumer.getAppId(), consumer.getName(),
                                 consumer.getOwnerName(), consumer.getOrgId())) {
    throw new BadRequestException("Params(appId、name、ownerName、orgId) can not be empty.");
  }

  Consumer createdConsumer = consumerService.createConsumer(consumer);

  if (expires == null) {
    expires = DEFAULT_EXPIRES;
  }

  return consumerService.generateAndSaveConsumerToken(createdConsumer, expires);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:22,代码来源:ConsumerController.java

示例9: createConsumer

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@Transactional
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@RequestMapping(value = "/consumers", method = RequestMethod.POST)
public ConsumerToken createConsumer(@RequestBody Consumer consumer,
                                    @RequestParam(value = "expires", required = false)
                                    @DateTimeFormat(pattern = "yyyyMMddHHmmss") Date
                                        expires) {

  if (StringUtils.isContainEmpty(consumer.getAppId(), consumer.getName(),
                                 consumer.getOwnerName(), consumer.getOrgId())) {
    throw new BadRequestException("Params(appId、name、ownerName、orgId) can not be empty.");
  }

  Consumer createdConsumer = consumerService.createConsumer(consumer);

  if (Objects.isNull(expires)) {
    expires = DEFAULT_EXPIRES;
  }

  return consumerService.generateAndSaveConsumerToken(createdConsumer, expires);
}
 
开发者ID:ctripcorp,项目名称:apollo,代码行数:22,代码来源:ConsumerController.java

示例10: listAllUserProjects

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<UserProject>> listAllUserProjects(
		Principal principal,
		@RequestParam(value="_page", required=false) Integer page, 
		@RequestParam(value="_perPage", required=false) Integer perPage,
		@RequestParam(value="_sortField", required=false) String sortField,
		@RequestParam(value="_sortDir", required=false) String sortDir,
		@RequestParam(value="project", required=false) String projectId,
		@RequestParam(value="user", required=false) String userId,
		@RequestParam(value="before", required=false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startBefore,
		@RequestParam(value="after", required=false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate finishAfter) {
	
	logger.info("Fetching user's projects. Params: ");
	
	Pageable pageable = getPagiable(page, perPage, sortDir, sortField);
	
	List<String> projects = getAvailableProjects(principal);
	projects = projectId == null ? projects : Arrays.asList(projectId);
	
	Page<UserProject> upList = userService.getUserProjects(projects, userId, startBefore, finishAfter, pageable);
	
    return new ResponseEntity<>(upList.getContent(), generatePaginationHeaders(upList, ""), HttpStatus.OK);
}
 
开发者ID:denis-rodionov,项目名称:cityoffice,代码行数:24,代码来源:UserProjectController.java

示例11: search

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
/**
 * Handle the GET method by searching for Bananas
 *
 * @param pickedAfter a DateTime to filter Bananas that have a pickedAt greater than
 * @param peeled filter for Bananas with matching peeled value
 * @return a list of BananaResource representations of the matching Bananas
 */
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody List<BananaResource> search(
        @RequestParam(value="pickedAfter", required=false)
        @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME)
                LocalDateTime pickedAfter,
        @RequestParam(value="peeled", required=false)
                Boolean peeled) {

  return bananaRepository
          .findAll()
          .stream()
          .filter(b -> {
            if (Objects.nonNull(pickedAfter) && b.getPickedAt().isBefore(pickedAfter)) {
              return false;
            } else if (Objects.nonNull(peeled) && !b.getPeeled().equals(peeled)) {
              return false;
            } else {
              return true;
            }
          })
          .map(bananaResourceAssembler::toResource)
          .collect(Collectors.toList());
}
 
开发者ID:stelligent,项目名称:microservice-exemplar,代码行数:31,代码来源:BananaController.java

示例12: updateRespondByDate

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@PutMapping("/claims/{claimReferenceNumber}/response-deadline/{newDeadline}")
@ApiOperation("Manipulate the respond by date of a claim")
public Claim updateRespondByDate(
    @PathVariable("claimReferenceNumber") String claimReferenceNumber,
    @PathVariable("newDeadline") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate newDeadline
) {
    Claim claim = getByClaimReferenceNumber(claimReferenceNumber);

    testingSupportRepository.updateResponseDeadline(claim.getId(), newDeadline);

    return getByClaimReferenceNumber(claimReferenceNumber);
}
 
开发者ID:hmcts,项目名称:cmc-claim-store,代码行数:13,代码来源:IntegrationTestSupportController.java

示例13: calculateInterest

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@GetMapping("/calculate")
@ApiOperation("Calculates interest rate")
public InterestAmount calculateInterest(
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @RequestParam("from_date") LocalDate from,
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @RequestParam("to_date") LocalDate to,
    @RequestParam("rate") BigDecimal rate,
    @RequestParam("amount") BigDecimal amount
) {
    try {
        return new InterestAmount(TotalAmountCalculator.calculateInterest(amount, rate, from, to));
    } catch (IllegalArgumentException | NullPointerException e) {
        throw new BadRequestException(e.getMessage(), e);
    }
}
 
开发者ID:hmcts,项目名称:cmc-claim-store,代码行数:15,代码来源:InterestRatesController.java

示例14: getByDates

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET,
    params = {"fromDate", "toDate"})
public List<AuditEvent> getByDates(
    @RequestParam(value = "fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
    @RequestParam(value = "toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate) {

    return auditEventService.findByDates(fromDate.atTime(0, 0), toDate.atTime(23, 59));
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:9,代码来源:AuditResource.java

示例15: schedules

import org.springframework.format.annotation.DateTimeFormat; //导入依赖的package包/类
/**
 * 查询指定会议室下指定日期区间的排期.
 * 
 * @param id 会议室 id
 * @param date 指定日期
 * @return 指定的会议室指定日期的排期列表
 */
@RequestMapping(path = "/meetingRooms/{id}/schedule", method = RequestMethod.GET)
public Result<List<Schedule>> schedules(@PathVariable Long id,
		@RequestParam(name = "date") @DateTimeFormat(pattern = DateUtils.PATTERN_SIMPLE_DATE) Date date) {
	return DefaultResult.newResult(scheduleService.find(id, date).stream().map(s -> {
		User user = userRepository.findOneByOpenId(s.getCreatorOpenId());
		s.setCreatorNickName(s.getCreatorNickName() + "/" + user.getName());
		return s;
	}).collect(Collectors.toList()));
}
 
开发者ID:7upcat,项目名称:agile-wroking-backend,代码行数:17,代码来源:MeetingRoomController.java


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