如何在相同的输入日期上添加日期和时间?

问题描述 投票:0回答:1

如果添加日期,则输入日期默认在以下时间修改01/01/1970 08:00:00提交期间

例如:DispDeb = 02/08/2019DispFin 02/08/2019,但在DispDeb 08:00DispFin 12:00中的时间

我的问题

如果在inputText中的DispDeb 02/08/2019Time中添加日期08:00更改我在DispDebDispFin中的日期,并在我的提交中将其添加到表DispDeb 01/01/1970 08:00DispFin 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;
    }``
java oracle-adf data-conversion
1个回答
0
投票

我不太确定您要从问题中尝试做什么,但是可以简化转换过程

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);

希望有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.