Fix MTS sql syntax error and month error
This commit is contained in:
@@ -23,6 +23,8 @@ package server;
|
||||
|
||||
import client.inventory.Item;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
@@ -38,13 +40,16 @@ public class MTSItemInfo {
|
||||
private int day = 1;
|
||||
|
||||
public MTSItemInfo(Item item, int price, int id, int cid, String seller, String date) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate sellEnd = LocalDate.parse(date, formatter);
|
||||
|
||||
this.item = item;
|
||||
this.price = price;
|
||||
this.seller = seller;
|
||||
this.id = id;
|
||||
this.year = Integer.parseInt(date.substring(0, 4));
|
||||
this.month = Integer.parseInt(date.substring(5, 7));
|
||||
this.day = Integer.parseInt(date.substring(8, 10));
|
||||
this.year = sellEnd.getYear();
|
||||
this.month = sellEnd.getMonthValue();
|
||||
this.day = sellEnd.getDayOfMonth();
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
|
||||
Reference in New Issue
Block a user