Java - printing date (as strings) with javafx - printing current date

Here is the code from my patient class and the code JavaFx

to display it. However, every time I add a new object to the queue and update, the displayed time is the current time, not every single time ... `

public String getTime() {
    DateTime d = new DateTime();

    String s = null;
    s = d.toString();

    return s;
}

public void setTime(String time) {
    this.time = time;
}

      

I use jodatime

to convert the current datetime

to string

and then display that ...

@FXML
private TableColumn<Patient, String> timeColumn;

timeColumn.setCellValueFactory(new PropertyValueFactory<Patient, String>("time"));

      

+3


source to share


1 answer


change your getTime () to:

 public String getTime() {

    DateTime d = new DateTime();

    String s = null;
    s = d.toString();

    return s;
}

      

to:



    public String getTime() {
    return this.time;
}

      

Since yours getTime()

keeps on giving currentTime and not the time you are storing using setTime()

.

+4


source







All Articles