gpt4 book ai didi

org.exolab.castor.types.Year类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 05:25:31 27 4
gpt4 key购买 nike

本文整理了Java中org.exolab.castor.types.Year类的一些代码示例,展示了Year类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Year类的具体详情如下:
包路径:org.exolab.castor.types.Year
类名称:Year

Year介绍

[英]Describe an XML schema Year.

The date type is derived from time period by setting up the facet :

  • duration to "P1Y"

Note: This datatype is not included in any recommendation. It was introduced in http://www.w3.org/TR/2000/WD-xmlschema-2-20000407/ and was last in http://www.w3.org/TR/2000/CR-xmlschema-2-20001024/ and was removed by http://www.w3.org/TR/2001/PR-xmlschema-2-20010316/. It was not in the final approved recommendation: http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/
[中]请描述一个XML模式。
日期类型是通过设置方面从时间段派生的:
*“P1Y”的持续时间
注:此数据类型不包含在任何建议中。它是在年引入的http://www.w3.org/TR/2000/WD-xmlschema-2-20000407/是最后一个进来的http://www.w3.org/TR/2000/CR-xmlschema-2-20001024/并被http://www.w3.org/TR/2001/PR-xmlschema-2-20010316/.最终批准的建议中没有:http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/

代码示例

代码示例来源:origin: org.codehaus.castor/castor-xml

/**
 * Creates a new instance of the object described by this field.
 *
 * @param parent The object for which the field is created
 * @return A new instance of the field's value
 * @throws IllegalStateException This field is a simple type and cannot be instantiated
 */
public Object newInstance(Object parent) throws IllegalStateException {
 return new Year();
} // -- newInstance

代码示例来源:origin: org.codehaus.castor/castor-xml

/**
 * parse a String and convert it into a java.lang.Object
 * 
 * @param str the string to parse
 * @return the java.lang.Object represented by the string
 * @throws ParseException a parse exception is thrown if the string to parse does not follow the
 *         rigth format (see the description of this class)
 */
public static Object parse(String str) throws ParseException {
 return parseYear(str);
}

代码示例来源:origin: org.codehaus.castor/castor-xml

public java.util.Date toDate() throws ParseException {
 java.util.Date date = null;
 SimpleDateFormat df = new SimpleDateFormat(YEAR_FORMAT);
 SimpleTimeZone timeZone = new SimpleTimeZone(0, "UTC");
 // Set the time zone
 if (!isUTC()) {
  int offset = 0;
  offset = ((this.getZoneMinute() + this.getZoneHour() * 60) * 60 * 1000);
  offset = isZoneNegative() ? -offset : offset;
  timeZone.setRawOffset(offset);
  timeZone.setID(TimeZone.getAvailableIDs(offset)[0]);
 }
 df.setTimeZone(timeZone);
 date = df.parse(this.toString());
 return date;
}// toDate()

代码示例来源:origin: org.codehaus.castor/castor-xml

/**
 * Sets the value of the field associated with this descriptor.
 *
 * @param target the object in which to set the value
 * @param value the value of the field
 */
public void setValue(Object target, Object value) throws java.lang.IllegalStateException {
 if (!(target instanceof Year)) {
  // -- throw exception
 }
 Year yearTarget = (Year) target;
 if (value == null) {
  /// do something
 }
 // -- update current instance of time with new year
 try {
  Year temp = Year.parseYear(value.toString());
  yearTarget.setCentury(temp.getCentury());
  yearTarget.setYear(temp.getYear());
 } catch (Exception ex) {
  // -- ignore for now
 }
} // -- setValue

代码示例来源:origin: org.codehaus.castor/castor-xml

Year result = new Year();
 result.setNegative();
 str = str.substring(1);
 System.out.println("In parsing method of Year");
 System.out.println("String to parse : " + str);
 System.out.println("Negative ? " + result.isNegative());
 System.out.println("Processing century: " + str.substring(0, 2));
result.setCentury(Short.parseShort(str.substring(0, 2)));
if (DEBUG) {
 System.out.println("Processing year: " + str.substring(2, 4));
 result.setYear(Short.parseShort(str.substring(2, 4)));
} catch (UnsupportedOperationException e) {

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

/**
 * convert this Year to a string
 * The format is defined by W3C XML Schema draft and ISO8601
 * i.e (+|-)CCYY
 * @return a string representing this Month
 */
 public String toString() {
  StringBuffer result = new StringBuffer();
  result.append(this.getCentury());
  if (result.length() == 1)
    result.insert(0,0);
  if ((this.getYear()/10) == 0)
    result.append(0);
  result.append(this.getYear());
  if (isNegative())
    result.insert(0,'-');
  return result.toString();
}//toString

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

public java.util.Date toDate() throws ParseException {
  java.util.Date date = null;
  SimpleDateFormat df = new SimpleDateFormat(YEAR_FORMAT);
  SimpleTimeZone timeZone = new SimpleTimeZone(0,"UTC");
  // Set the time zone
  if ( !isUTC() ) {
    int offset = 0;
    offset = ( (this.getZoneMinute() + this.getZoneHour()*60)*60*1000);
    offset = isZoneNegative() ? -offset : offset;
    timeZone.setRawOffset(offset);
    timeZone.setID(TimeZone.getAvailableIDs(offset)[0]);
  }
  df.setTimeZone(timeZone);
  date = df.parse(this.toString());
  return date;
}//toDate()

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

/**
 * Sets the value of the field associated with this descriptor.
 *
 * @param target
 *            the object in which to set the value
 * @param value
 *            the value of the field
 */
public void setValue(Object target, Object value) throws java.lang.IllegalStateException {
  if (! (target instanceof Year) ) {
    //-- throw exception
  }
  Year yearTarget = (Year) target;
  if (value == null) {
    /// do something
  }
  //-- update current instance of time with new year
  try {
    Year temp = Year.parseYear(value.toString()) ;
    yearTarget.setCentury(temp.getCentury());
    yearTarget.setYear(temp.getYear());
  } catch (Exception ex) {
    //-- ignore for now
  }
} //-- setValue

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

Year result = new Year();
  result.setNegative();
  str =str.substring(1);
  System.out.println("In parsing method of Year");
  System.out.println("String to parse : "+str);
  System.out.println("Negative ? "+result.isNegative());
  System.out.println("Processing century: "+str.substring(0,2));
result.setCentury(Short.parseShort( str.substring(0,2) ));
if (DEBUG) {
  System.out.println("Processing year: "+str.substring(2,4));
  result.setYear(Short.parseShort( str.substring(2,4) ));
} catch(UnsupportedOperationException e) {

代码示例来源:origin: org.codehaus.castor/castor-xml

/**
 * convert this Year to a string The format is defined by W3C XML Schema draft and ISO8601 i.e
 * (+|-)CCYY
 * 
 * @return a string representing this Month
 */
public String toString() {
 StringBuilder result = new StringBuilder();
 result.append(this.getCentury());
 if (result.length() == 1)
  result.insert(0, 0);
 if ((this.getYear() / 10) == 0)
  result.append(0);
 result.append(this.getYear());
 if (isNegative())
  result.insert(0, '-');
 return result.toString();
}// toString

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

/**
* parse a String and convert it into a java.lang.Object
* @param str the string to parse
* @return the java.lang.Object represented by the string
* @throws ParseException a parse exception is thrown if the string to parse
*                        does not follow the rigth format (see the description
*                        of this class)
*/
public static Object parse(String str) throws ParseException {
  return parseYear(str);
}

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

/**
 * Creates a new instance of the object described by this field.
 *
 * @param parent
 *            The object for which the field is created
 * @return A new instance of the field's value
 * @throws IllegalStateException
 *             This field is a simple type and cannot be instantiated
 */
public Object newInstance(Object parent) throws IllegalStateException {
  return new Year();
} //-- newInstance

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com