0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

inputフォームのカンマ設定処理

Posted at

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@GetMapping("/search")
public String searchProjects(
@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate,
Model model
) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

LocalDateTime start = (startDate != null && !startDate.isEmpty()) 
                      ? LocalDate.parse(startDate, formatter).atStartOfDay() 
                      : null;

LocalDateTime end = (endDate != null && !endDate.isEmpty()) 
                    ? LocalDate.parse(endDate, formatter).atTime(23, 59, 59) 
                    : null;

List<Project> projects = projectService.searchByContractDate(start, end);
model.addAttribute("projects", projects);
return "search";

}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?