Converting a Java class to a DTO implementation

Report a typo

Implement the method that converts a Product to a ProductDTO object. The method should accept a Product instance and return an instance of ProductDTO created from the given Product.

Sample Input 1:

No input.

Sample Output 1:

Good job!
Write a program in Java 17
class Product {
private long id;
private String model;
private int price;
private LocalDate dateOfArrival;
private String vendor;

public Product(long id, String model, int price, LocalDate dateOfArrival, String vendor) {
this.id = id;
this.model = model;
this.price = price;
this.dateOfArrival = dateOfArrival;
this.vendor = vendor;
}

public Product() { }

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public int getPrice() {
return price;
}
___

Create a free account to access the full topic