[英]How to add Date And Time on the same Input Date?
如果添加日期然后时间 inputDate 修改默认为 01/01/1970 08:00:00 在提交期间
例如:
DispDeb = 02/08/2019
和DispFin 02/08/2019
但时间在DispDeb 08:00
和在DispFin 12:00
我的问题
如果在DispDeb 02/08/2019
添加日期DispDeb 02/08/2019
和Time
在 inputText 08:00
更改我在DispDeb
和DispFin
日期,并在我的提交中添加到表DispDeb 01/01/1970 08:00
和DispFin 01/01/1970 12:00 Error javax.DateTimeConverter converter
<af:inputDate value="#{bindings.DispDeb.inputValue}"
binding="#{pageFlowScope.PlaningCalBean.dateDebvalue}"
id="id1" label="#{bindings.DispDeb.hints.label}" contentStyle="width:100px;" >
<af:convertDateTime pattern="dd/MM/yyyy"/>
</af:inputDate>'
<af:inputText label="Heure Début" id="it4" value="#{bindings.DispDeb.inputValue}"
contentStyle="width:50px;text-align:center;"
binding="#{pageFlowScope.PlaningCalBean.heursdateDebvalue}">
<af:convertDateTime pattern="HH:mm"/>
</af:inputText>
`
`
` public String savegarde() throws ParseException {
// Add event code here...
String DateDebut = null , DateDebHeurs = null , docDatesHeursFin = null ;
SimpleDateFormat ft = new SimpleDateFormat("HH:mm:ss");
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DateDebut = formatter.format(this.getDateDebvalue().getValue());
DateDebHeurs = ft.format(this.getHeursdateDebvalue().getValue());
docDatesHeursFin = ft.format(this.getHeursdatefinvalue().getValue());
int year=Integer.parseInt(DateDebut.split("/")[2]);
int month=Integer.parseInt(DateDebut.split("/")[1]);
int day=Integer.parseInt(DateDebut.split("/")[0]);
Integer hour = Integer.parseInt(DateDebHeurs.split(":")[0]);
Integer minute = Integer.parseInt(DateDebHeurs.split(":")[1]);
Integer second = Integer.parseInt(DateDebHeurs.split(":")[2]);
Integer hours = Integer.parseInt(docDatesHeursFin.split(":")[0]);
Integer minutes = Integer.parseInt(docDatesHeursFin.split(":")[1]);
Integer seconds = Integer.parseInt(docDatesHeursFin.split(":")[2]);
LocalDateTime dateTimez = LocalDateTime.of(year, month, day, hour, minute, second);
LocalDateTime dateTimezFin = LocalDateTime.of(year, month, day, hours, minutes, seconds);
System.out.println(dateTimez + " aloooo " + dateTimezFin);
Date date= Date.from(dateTimez.atZone(ZoneId.systemDefault()).toInstant());
Timestamp ts =new Timestamp(date.getTime());
Date datez= Date.from(dateTimezFin.atZone(ZoneId.systemDefault()).toInstant());
Timestamp tzs =new Timestamp(datez.getTime());
System.out.println(ts + " aloooo " + tzs);
oracle.adf.model.AttributeBinding dateDebutattr = (oracle.adf.model.AttributeBinding)bindings.getControlBinding("DispDeb");
dateDebutattr.setInputValue(ts);
BindingContainer bindingsss = getBindings();
OperationBinding operationBindingss = bindingsss.getOperationBinding("Commit");
operationBindingss.execute();
return null;
}``
我不太确定你想从问题中做什么,但你可以简化转换
DispDeb = 02/08/2019 and DispDeb 08:00
像这样:
DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm")
.withZone(ZoneId.systemDefault());
String date = "2019/12/19";
String time = "12:00";
String dateTime = date + " " + time;
LocalDateTime localDateTime = LocalDateTime.parse(dateTime, DATE_TIME_FORMATTER);
System.out.println(localDateTime);
Timestamp timestamp = Timestamp.valueOf(localDateTime);
System.out.println(timestamp);
希望有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.