Java Code Examples for org.springframework.format.annotation.DateTimeFormat.ISO#DATE

The following examples show how to use org.springframework.format.annotation.DateTimeFormat.ISO#DATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDateFilter.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
@DateTimeFormat(iso = ISO.DATE)
public LocalDateFilter setGreaterThanOrEqual(LocalDate equals) {
    super.setGreaterThanOrEqual(equals);
    return this;
}
 
Example 2
Source File: UserAPIController.java    From onboard with Apache License 2.0 5 votes vote down vote up
/**
 * 看一个人完成的所有todo
 * 
 * @param companyId
 * @param userId
 * @param model
 * @return
 */
@RequestMapping(value = "/{companyId}/user/{userId}/completed_todos", method = RequestMethod.GET)
@Interceptors({ CompanyMemberRequired.class, UserChecking.class })
@ResponseBody
public Map<String, Object> viewUserCompletedTodos(@PathVariable int companyId, @PathVariable int userId,
        @RequestParam(value = "until", required = false) @DateTimeFormat(iso = ISO.DATE) Date until, Model model) {
    Builder<String, Object> builder = ImmutableMap.builder();
    DateTime dt = until == null ? new DateTime() : new DateTime(until);
    until = dt.withTime(0, 0, 0, 0).plusDays(1).plusMillis(-1).toDate();
    List<Integer> projectList = getProjectListOfCurrentUser(companyId);

    TreeMap<Date, List<Todolist>> map = todoService.getCompletedTodolistsGroupByDateByUser(companyId, userId,
            projectList, until, PER_PAGE);
    TreeMap<String, List<TodolistDTO>> mapDTO = makeUserCompletedTodosMapSerilizable(map);
    builder.put("completedTodos", mapDTO);
    Map<Integer, String> projectIdToName = getProjectIdAndNameByCompanyId(companyId);
    builder.put("projectsName", projectIdToName);

    boolean hasNext = false;

    if (map != null && map.size() > 0) {
        Date newUntil = new DateTime(map.lastKey()).withTime(0, 0, 0, 0).plusMillis(-1).toDate();

        TreeMap<Date, List<Todolist>> nextMap = todoService.getCompletedTodolistsGroupByDateByUser(companyId,
                userId, projectList, newUntil, PER_PAGE);
        hasNext = nextMap.size() > 0;
        builder.put("nextPage", dtf.print(new DateTime(newUntil)));
    }

    builder.put("hasNext", hasNext);

    return builder.build();
}
 
Example 3
Source File: LocalDateFilter.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
@DateTimeFormat(iso = ISO.DATE)
public LocalDateFilter setGreaterThan(LocalDate equals) {
    super.setGreaterThan(equals);
    return this;
}
 
Example 4
Source File: LocalDateFilter.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
@DateTimeFormat(iso = ISO.DATE)
public LocalDateFilter setEquals(LocalDate equals) {
    super.setEquals(equals);
    return this;
}
 
Example 5
Source File: LocalDateFilter.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
@DateTimeFormat(iso = ISO.DATE)
@Deprecated
public LocalDateFilter setGreaterOrEqualThan(LocalDate equals) {
    super.setGreaterOrEqualThan(equals);
    return this;
}
 
Example 6
Source File: LocalDateFilter.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
@DateTimeFormat(iso = ISO.DATE)
public LocalDateFilter setIn(List<LocalDate> in) {
    super.setIn(in);
    return this;
}
 
Example 7
Source File: ActivityApiController.java    From onboard with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/activities", method = RequestMethod.GET)
@Interceptors({ CompanyMemberRequired.class })
@ResponseBody
public CompanyActivities showActivities(@PathVariable int companyId, @RequestParam(value = "until",
        required = false) @DateTimeFormat(iso = ISO.DATE) Date until,
        @RequestParam(required = false) Integer userId, @RequestParam(required = false) Integer projectId,
        @RequestParam(required = false) String type) {
    DateTime dt = until == null ? new DateTime() : new DateTime(until);
    until = dt.withTime(0, 0, 0, 0).plusDays(1).plusMillis(-1).toDate();
    boolean hasNext = false;
    Date nextDay = null;

    List<Activity> activities = activityService.getUserVisibleTillDay(companyId, userId, projectId, until, type,
            LIMIT);

    if (activities.size() > 0) {

        Activity activity = activities.get(activities.size() - 1);
        nextDay = new DateTime(activity.getCreated()).withTime(0, 0, 0, 0).plusMillis(-1).toDate();

        // 如果取到nextDay仍然有数据,则hasNext为true
        List<Activity> nextActivities = activityService.getUserVisibleTillDay(companyId, userId, projectId,
                nextDay, type, LIMIT);

        if (nextActivities.size() > 0) {
            hasNext = true;
        }
    }
    return new CompanyActivities(activities, hasNext, nextDay);
}
 
Example 8
Source File: WebMvcConfigurationSupportTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@RequestMapping("/foo/{id}/bar/{date}")
public HttpEntity<Void> methodWithTwoPathVariables(@PathVariable Integer id,
		@DateTimeFormat(iso = ISO.DATE) @PathVariable DateTime date) {
	return null;
}
 
Example 9
Source File: MvcUriComponentsBuilderTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@RequestMapping("/{id}/foo/{date}")
HttpEntity<Void> methodWithTwoPathVariables(
		@PathVariable Integer id, @DateTimeFormat(iso = ISO.DATE) @PathVariable DateTime date) {
	return null;
}
 
Example 10
Source File: WebMvcConfigurationSupportTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@RequestMapping("/foo/{id}/bar/{date}")
public HttpEntity<Void> methodWithTwoPathVariables(@PathVariable Integer id,
		@DateTimeFormat(iso = ISO.DATE) @PathVariable DateTime date) {
	return null;
}
 
Example 11
Source File: MvcUriComponentsBuilderTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@RequestMapping("/{id}/foo/{date}")
HttpEntity<Void> methodWithTwoPathVariables(
		@PathVariable Integer id, @DateTimeFormat(iso = ISO.DATE) @PathVariable DateTime date) {
	return null;
}
 
Example 12
Source File: Product.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@DateTimeFormat(iso = ISO.DATE)
public LocalDateTime getEmbargoDate() {
	return embargoDate;
}
 
Example 13
Source File: HistoricalReportController.java    From cf-butler with Apache License 2.0 4 votes vote down vote up
@GetMapping(value = { "/policies/report" }, produces = MediaType.TEXT_PLAIN_VALUE)
public Mono<ResponseEntity<String>> generateReport(
	@DateTimeFormat(iso = ISO.DATE)
	@RequestParam(required = false, value = "start")
	LocalDate start,
	@DateTimeFormat(iso = ISO.DATE)
	@RequestParam(required = false, value = "end")
	LocalDate end) {
	Mono<ResponseEntity<String>> result = null;
	boolean hasDateRange = start != null && end != null;
	boolean hasValidDateRange = hasDateRange && start.isBefore(end);
	if (!hasDateRange) {
		result = historicalRecordService
				.findAll()
				.collectList()
				.map(r ->
					new HistoricalRecordRetrievedEvent(this)
						.records(r)
				)
				.delayElement(Duration.ofMillis(500))
				.map(e -> ResponseEntity.ok(
							String.join(
									"\n\n",
									report.generatePreamble(),
									report.generateDetail(e))))
				.defaultIfEmpty(ResponseEntity.notFound().build());
	} else if (hasValidDateRange) {
		result = historicalRecordService
				.findByDateRange(start, end)
				.collectList()
				.map(r ->
					new HistoricalRecordRetrievedEvent(this)
						.records(r)
				)
				.delayElement(Duration.ofMillis(500))
				.map(e -> ResponseEntity.ok(
							String.join(
									"\n\n",
									report.generatePreamble(),
									report.generateDetail(e))))
				.defaultIfEmpty(ResponseEntity.notFound().build());
	} else {
		log.error("The start date must be before end date when fetching historical records contrained by a date range.");
		result = Mono.just(ResponseEntity.badRequest().build());
	}
	return result;
}
 
Example 14
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedAfter(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date date); 
Example 15
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedBetween(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date after,@Param("before") @DateTimeFormat(iso = ISO.DATE) Date before); 
Example 16
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedBetween(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date after,@Param("before") @DateTimeFormat(iso = ISO.DATE) Date before); 
Example 17
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedBetween(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date after,@Param("before") @DateTimeFormat(iso = ISO.DATE) Date before); 
Example 18
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedAfter(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date date); 
Example 19
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedAfter(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date date); 
Example 20
Source File: JournalRepository.java    From pro-spring-boot with Apache License 2.0 votes vote down vote up
List<JournalEntry> findByCreatedBetween(@Param("after") @DateTimeFormat(iso = ISO.DATE) Date after,@Param("before") @DateTimeFormat(iso = ISO.DATE) Date before);