Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2011 IBM. All rights reserved. Use is subject to license terms. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also obtain a copy of the License at http://odftoolkit.org/docs/license.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package org.odftoolkit.simple.common.field;
 
 import java.util.Date;
 
TimeField displays a time, by default this is the current time.

Since:
0.5
 
 public class TimeField extends Field {

The default time format of time field.
 
 	private static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";

The default time value format.
 
 	private static final String DEFAULT_TIME_VALUE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.S";
 
 
 	// package constructor, only called by Fields.
 	TimeField(OdfElement odfElement) {
 		TextSpanElement spanElement = ((OdfFileDomodfElement.getOwnerDocument()).newOdfElement(TextSpanElement.class);
 		odfElement.appendChild(spanElement);
 		 = spanElement.newTextTimeElement();
 		OdfNumberTimeStyle timeStyle = newTimeStyle();
 		String timeStyleName = timeStyle.getStyleNameAttribute();
 		timeStyle.setStyleNameAttribute(timeStyleName);
 		Calendar calender = Calendar.getInstance();
 		Date time = calender.getTime();
 		String svalue = simpleFormat.format(time);
 		.setTextContent(contentFormat.format(time));
 	}

Set the format of this time field. Time format pattern is the same as SimpleDateFormat.

Parameters:
formatString the format string of this time.
See also:
java.text.SimpleDateFormat
 
 	public void formatTime(String formatString) {
 		try {
 			Date simpleDate = simpleFormat.parse(sValue);
 			SimpleDateFormat newFormat = new SimpleDateFormat(formatString);
 			.setTextContent(newFormat.format(simpleDate));
 			dataStyle.buildFromFormat(formatString);
 		} catch (ParseException e) {
 			Logger.getLogger(TimeField.class.getName()).log(.e.getMessage(), e);
 		}
 	}

Set whether the time value of this field is fixed.

Parameters:
isFixed if true, the time value shall be preserved, otherwise it may be replaced with a new value in future edits.
	public void setFixed(boolean isFixed) {
	}

Return an instance of TextTimeElement which represents this feature.

Returns:
an instance of TextTimeElement
		return ;
	}
	// Create an <code>OdfNumberTimeStyle</code> element
		styles.appendChild(newStyle);
		return newStyle;
	}
		String unique_name;
		do {
			unique_name = String.format("N%06x", (int) (Math.random() * 0xffffff));
while (styles.getTimeStyle(unique_name) != null);
		return unique_name;
	}
	public FieldType getFieldType() {
	}
New to GrepCode? Check out our FAQ X