comparison src/classes/java/text/SimpleDateFormat.java @ 0:61d41facf527

initial v8 import (history reset)
author Peter Mehlitz <Peter.C.Mehlitz@nasa.gov>
date Fri, 23 Jan 2015 10:14:01 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:61d41facf527
1 /*
2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
4 * All rights reserved.
5 *
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package java.text;
20
21 import java.util.Calendar;
22 import java.util.Date;
23 import java.util.Locale;
24 import java.util.TimeZone;
25
26 /**
27 * (incomplete) model class for java.text.SimpleDate. See Format for details
28 * about the native formatter delegation
29 */
30 public class SimpleDateFormat extends DateFormat {
31
32 // see DecimalFormat comments why we use explicit init0()'s
33
34 private native void init0();
35 private native void init0(String pattern);
36 private native void init0(int timeStyle, int dateStyle);
37
38 public SimpleDateFormat () {
39 init0();
40 initializeCalendar();
41 }
42
43 public SimpleDateFormat (String pattern) {
44 if(pattern == null) {
45 throw new NullPointerException();
46 }
47 init0(pattern);
48 initializeCalendar();
49 }
50
51 public SimpleDateFormat (String pattern, Locale locale) {
52 // <2do> bluntly ignoring locale for now
53 this(pattern);
54 }
55
56 SimpleDateFormat (int timeStyle, int dateStyle, Locale locale){
57 init0(timeStyle, dateStyle);
58 initializeCalendar();
59 }
60
61 // unfortunately we can't override the DateFormat.format(String) because
62 // it is final, and hence the compiler can do a INVOKE_SPECIAL
63 native String format0 (long dateTime);
64
65 @Override
66 public StringBuffer format (Date date, StringBuffer sb, FieldPosition pos) {
67 String s = format0(date.getTime());
68 sb.append(s);
69
70 // we don't do FieldPositions yet
71
72 return sb;
73 }
74
75
76 @Override
77 public Date parse (String arg0, ParsePosition arg1) {
78 // TODO Auto-generated method stub
79 return null;
80 }
81
82 private void initializeCalendar() {
83 if (calendar == null) {
84 calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
85 }
86 }
87
88 native public void applyPattern(String pattern);
89
90 }