1 package org.apache.maven.continuum.web.view.commons;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.codehaus.plexus.util.StringUtils;
23 import org.extremecomponents.table.bean.Column;
24 import org.extremecomponents.table.cell.DisplayCell;
25 import org.extremecomponents.table.core.TableModel;
26 import org.extremecomponents.util.ExtremeUtils;
27
28 import java.util.Calendar;
29 import java.util.Locale;
30
31 /**
32 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
33 * @version $Id: DateCell.java 765385 2009-04-15 21:56:46Z evenisse $
34 * @deprecated use of cells is discouraged due to lack of i18n and design in java code.
35 * Use jsp:include instead.
36 */
37 public class DateCell
38 extends DisplayCell
39 {
40 protected String getCellValue( TableModel tableModel, Column column )
41 {
42 String valueString = column.getPropertyValueAsString();
43
44 if ( !StringUtils.isEmpty( valueString ) && !"0".equals( valueString ) )
45 {
46 Locale locale = tableModel.getLocale();
47
48 Object value = column.getPropertyValue();
49
50 if ( value instanceof Long )
51 {
52 Calendar cal = Calendar.getInstance();
53
54 cal.setTimeInMillis( (Long) value );
55
56 value = cal.getTime();
57 }
58
59 String format = column.getFormat();
60
61 if ( StringUtils.isEmpty( format ) )
62 {
63 format = "MMM dd, yyyy hh:mm:ss aaa z";
64 }
65
66 value = ExtremeUtils.formatDate( column.getParse(), format, value, locale );
67
68 column.setPropertyValue( value );
69
70 return value.toString();
71 }
72 else
73 {
74 return " ";
75 }
76 }
77 }