View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.example.demo;
21  
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  
25  import javax.enterprise.context.RequestScoped;
26  import javax.inject.Named;
27  import java.io.Serializable;
28  import java.lang.invoke.MethodHandles;
29  import java.text.ParseException;
30  import java.text.SimpleDateFormat;
31  import java.util.Date;
32  
33  @RequestScoped
34  @Named
35  public class DateController implements Serializable {
36  
37    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
38  
39    private Date once;
40    private Date onchange;
41    private Date submitDate;
42  
43    public DateController() {
44      once = new Date();
45      final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
46      try {
47        submitDate = sdf.parse("2016-05-22");
48      } catch (final ParseException e) {
49        LOG.error("", e);
50      }
51    }
52  
53    public Date getOnce() {
54      return once;
55    }
56  
57    public void setOnce(final Date once) {
58      this.once = once;
59    }
60  
61    public Date getOnchange() {
62      return onchange;
63    }
64  
65    public void setOnchange(final Date onchange) {
66      this.onchange = onchange;
67    }
68  
69    public Date getNow() {
70      return new Date();
71    }
72  
73    public Date getSubmitDate() {
74      return submitDate;
75    }
76  
77    public void setSubmitDate(final Date submitDate) {
78      this.submitDate = submitDate;
79    }
80  }