Java 如何在同一输入日期上添加日期和时间?
如果添加日期,则默认情况下在中修改inputDate的时间 1970年1月1日08:00:00提交期间 例如:Java 如何在同一输入日期上添加日期和时间?,java,oracle-adf,data-conversion,Java,Oracle Adf,Data Conversion,如果添加日期,则默认情况下在中修改inputDate的时间 1970年1月1日08:00:00提交期间 例如: DispDeb=2019年8月2日和DispFin 2019年8月2日但时间在DispDeb 08:00和DispFin 12:00 我的问题 如果将日期添加到2019年8月2日的DispDeb中,并将时间添加到inputText中 08:00在DispDeb和DispFin中更改我的日期,并在我的提交中添加到表DispDeb 01/01/1970 08:00和DispFin 01/0
DispDeb=2019年8月2日
和DispFin 2019年8月2日
但时间在DispDeb 08:00
和DispFin 12:00
我的问题
如果将日期添加到2019年8月2日的DispDeb中,并将时间添加到inputText中
08:00
在DispDeb
和DispFin
中更改我的日期,并在我的提交中添加到表DispDeb 01/01/1970 08:00
和DispFin 01/01/1970 12:00
错误javax.DateTimeConverter转换器
<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;
}``
'
`
`
`公共字符串savegarde()引发ParseException{
//在此处添加事件代码。。。
字符串datedebunch=null,DateDebHeurs=null,docDatesHeursFin=null;
SimpleDateFormat ft=新的SimpleDateFormat(“HH:mm:ss”);
DateFormat格式化程序=新的SimpleDateFormat(“dd/MM/yyyy”);
BindingContainer bindings=BindingContext.getCurrent().getCurrentBindingsEntry();
DateFirst=formatter.format(this.getDateDebvalue().getValue());
DateDebHeurs=ft.format(this.getHeursdateDebvalue().getValue());
docDatesHeursFin=ft.format(this.getHeursdatefinvalue().getValue());
int year=Integer.parseInt(date处子秀.split(“/”[2]);
int month=Integer.parseInt(date处子秀.split(“/”[1]);
int day=Integer.parseInt(date处子秀.split(“/”[0]);
整数小时=整数.parseInt(DateDebHeurs.split(“:”[0]);
整数分钟=Integer.parseInt(DateDebHeurs.split(“:”[1]);
整数秒=Integer.parseInt(DateDebHeurs.split(“:”[2]);
整数小时=整数.parseInt(docDatesHeursFin.split(“:”[0]);
整数分钟=Integer.parseInt(docDatesHeursFin.split(“:”[1]);
整数秒=Integer.parseInt(docDatesHeursFin.split(“:”[2]);
LocalDateTime dateTimez=LocalDateTime.of(年、月、日、小时、分钟、秒);
LocalDateTime dateTimezFin=LocalDateTime.of(年、月、日、时、分、秒);
System.out.println(dateTimez+“aloooo”+dateTimezFin);
Date Date=Date.from(dateTimez.atZone(ZoneId.systemDefault()).toInstant());
Timestamp ts=新的时间戳(date.getTime());
Date datez=Date.from(dateTimezFin.atZone(ZoneId.systemDefault()).toInstant());
Timestamp tzs=新的时间戳(datez.getTime());
系统输出打印LN(ts+“ALOOO”+tzs);
oracle.adf.model.AttributeBinding dateDebutattr=(oracle.adf.model.AttributeBinding)bindings.getControlBinding(“DispDeb”);
DateDebutTR.setInputValue(ts);
BindingContainer bindingsss=getBindings();
OperationBinding operationBindingss=bindingsss.getOperationBinding(“提交”);
operationBindingss.execute();
返回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);
希望这有助于您的javaBean纠正问题,但在和中存在相同的值=“#{bindings.DispDeb.inputValue}”如果在inputText中发送我的时间,我的丢失日期更改为1970年1月1日,但我的时间在我的表中是正确的