How do i write a function for jasperreport in java spring boot

I’m trying to make a jasperreport, here’s the following code

Controller:


    @GetMapping("getX")
    public ResponseEntity<?> getX() throws IllegalAccessException, InvocationTargetException{
        return ResponseEntity.status(HttpStatus.OK).body(s.getX());
    }
    
    
    @PostMapping("saveY")
    public ResponseEntity<?> saveY(YDTO y){
        if(y.getName()==""||y.getSurname()=="") {
            throw new CustomException("custom");
        }
        if(y.getNumb().length()!=someNumb) {
            throw new CustomException2("custom2",y.getNumb().length());
        }
        Integer idNewY = s.saveY(y);
        if(idNewY == -1) {
            throw new CustomException3("custom3");
        }
        return ResponseEntity.ok("Success:" +idNewY);
        
    }
    
    
    @GetMapping("reportI")
    public ResponseEntity<?> getReport(String z) throws JRException, IOException{
        if(!s.existZ(z)) {
            throw new CustomException4("custom4", z);
        }
        byte[] report = s.createReport(z);
        if(report==null) {
            throw new CustomException4("custom4", z);
        }
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.parseMediaType("application/pdf"));
        headers.setContentDispositionFormData("attachment", "pdfName.pdf");
        return ResponseEntity.ok().headers(headers).body(report);
        
    }
    
    @ExceptionHandler(RuntimeException.class)
    public ResponseEntity<String> handleNotFoundZException(RuntimeException e){
        return ResponseEntity.badRequest().body("Error: "+e.getMessage());
    }

Service:

public List<XDTO> getX() throws IllegalAccessException, InvocationTargetException {
        List<X> x = xr.findAll();
        List<XDTO> xDTO = new LinkedList<>();
        for(X p: x) {
            XDTO dto = new XDTO();
            BeanUtils.copyProperties(p, dto);
            xDTO.add(dto);
        }
        return xDTO;
    }

    public int saveY(YDTO y) {
        Y newY = new Y();
        newY.setName(y.getName());
        newY.setSurname(y.getSurname());
        try {
            Y yc = yr.save(newY);
            return yc.getIdY();
        }catch(Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

    public boolean existZ(String z) {
        Z newZ = zr.findByName(z);
        if(newZ!=null) {
            return true;
        }
        return false;
    }

    public byte[] createReport(String z, and should be date) throws JRException, IOException {
        System.out.println("Number : "+ir.getIZ(z).size());
        if (ir.getIZ(z).size() > 0) {
            JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(ir.getIZ(z));
            java.io.InputStream inputStream = this.getClass().getResourceAsStream("/jasperreports/nameOfJrxml.jrxml");
            JasperReport jasperReport = JasperCompileManager.compileReport(inputStream);
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("z", z);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, dataSource);
            inputStream.close();
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            JRPdfExporter exporter = new JRPdfExporter();
            exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
            exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(byteArrayOutputStream));
            exporter.exportReport();
            return byteArrayOutputStream.toByteArray();
        }
        return null;
    }

Exception:

public class CustomException4 extends RuntimeException {

    private static final long serialVersionUID = 1L;
    
    public CustomException4(String message, String value) {
        super(message+", Value: "+value);
    }

}

I also have regular repo’s and dto’s
The report template is created, and the main issue is the date, i dont know how to use it in the report

Date needs to be parsed in some sort of way, do not know how

It needs the strict date format, i think its yyyy-mm-dd, MySQL Database is being used

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật