Using date, and date only, in java -
i'm writing java program , have been stuck quite while date, datetime , forth parts of java programming.
what want have date object only. have class:
deployment.java
public class deployment { int id; localdate devicedeploymentdate; //i'm unsure should public deployment(int id, localdate devicedeploymentdate) { this.id = id; this.devicedeploymentdate = devicedeploymentdate; } public deployment() { } public localdate getdevicedeploymentdate() { return devicedeploymentdate; } public void setdevicedeploymentdate(localdate date) { this.devicedeploymentdate = date; } public int getid() { return id; } public void setid(int id) { this.id = id; } }
and have date picker in gui.
from date picker can date in string format (and change int year, int month , int date if needed ofc). want store sort of date within deployment object, , not want time part of @ all.
question
which datatype should use this? , how do?
misc
i have shortly looked @ joda time, have been unable create localdate / datetime type either string or integers can date picker.
you can keep using localdate(as per david's comment) , use datetimeformatter joda time below convert string localdate.
final datetimeformatter dtf = datetimeformat.forpattern("yyyy-mmm-dd"); final localdate dt = dtf.parselocaldate(yourinputstring);
Comments
Post a Comment