java.text.SimpleDateFormat.compile()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(160)

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

SimpleDateFormat.compile介绍

[英]Returns the compiled form of the given pattern. The syntax of the compiled pattern is: CompiledPattern: EntryList EntryList: Entry EntryList Entry Entry: TagField TagField data TagField: Tag Length TaggedData Tag: pattern_char_index TAG_QUOTE_CHARS Length: short_length long_length TaggedData: TAG_QUOTE_ASCII_CHAR ascii_char where short_length' is an 8-bit unsigned integer between 0 and 254.long_length' is a sequence of an 8-bit integer 255 and a 32-bit signed integer value which is split into upper and lower 16-bit fields in two char's. pattern_char_index' is an 8-bit integer between 0 and 18.ascii_char' is an 7-bit ASCII character value. `data' depends on its Tag value.

If Length is short_length, Tag and short_length are packed in a single char, as illustrated below.

char[0] = (Tag << 8) | short_length; If Length is long_length, Tag and 255 are packed in the first char and a 32-bit integer, as illustrated below. char[0] = (Tag << 8) | 255; char[1] = (char) (long_length >>> 16); char[2] = (char) (long_length & 0xffff);

If Tag is a pattern_char_index, its Length is the number of pattern characters. For example, if the given pattern is "yyyy", Tag is 1 and Length is 4, followed by no data.

If Tag is TAG_QUOTE_CHARS, its Length is the number of char's following the TagField. For example, if the given pattern is "'o''clock'", Length is 7 followed by a char sequence of o&nbs;'&nbs;c&nbs;l&nbs;o&nbs;c&nbs;k.

TAG_QUOTE_ASCII_CHAR is a special tag and has an ASCII character in place of Length. For example, if the given pattern is "'o'", the TaggedData entry is ((TAG_QUOTE_ASCII_CHAR&nbs;<.
[中]返回给定模式的编译形式。编译模式的语法是:CompiledPattern:EntryList EntryList:Entry EntryList Entry:TagField TagField data TagField:Tag Length TaggedData:pattern\u char\u index Tag\u QUOTE\u CHARS Length:short\u Length long\u Length TaggedData:Tag\u QUOTE\u ASCII\u char ASCII\u char其中'short\u Length'是0到254之间的8位无符号整数“long_length”是一个8位整数255和一个32位带符号整数值的序列,该值在两个字符中分为上下16位字段。“pattern_char_index”是一个介于0和18之间的8位整数ascii_char'是一个7位ascii字符值“数据”取决于其标记值。 如果Length是short_Length,则将标记和short_Length打包在一个字符中,如下所示。 字符[0]=(标记<<8)|短|长度;如果Length是long_Length,则Tag和255被压缩在第一个字符和一个32位整数中,如下所示。字符[0]=(标记<8)| 255;字符[1]=(字符)(长长度>>>16);char[2]=(char)(long_length&0xffff); 如果标记是模式字符索引,则其长度为模式字符数。例如,如果给定的模式为“yyy”,则标记为1,长度为4,后跟无数据。 如果标记是Tag_QUOTE_CHARS,则其长度是标记字段后面的字符数。例如,如果给定的模式是“o”“clock”,则长度为7,后跟字符序列o&nbs;'&nbs;c&nbs;l&nbs;o&nbs;c&nbs;k。 TAG_QUOTE_ASCII_CHAR是一个特殊的标记,用ASCII字符代替长度。例如,如果给定的模式是“o”,则TaggedData条目是((TAG_QUOTE_ASCII_CHAR&nbs;<. `

代码示例

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Applies the given pattern string to this date format.
 *
 * @param pattern the new date and time pattern for this date format
 * @exception NullPointerException if the given pattern is null
 * @exception IllegalArgumentException if the given pattern is invalid
 */
public void applyPattern(String pattern)
{
  compiledPattern = compile(pattern);
  this.pattern = pattern;
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Applies the given pattern string to this date format.
 *
 * @param pattern the new date and time pattern for this date format
 * @exception NullPointerException if the given pattern is null
 * @exception IllegalArgumentException if the given pattern is invalid
 */
public void applyPattern(String pattern)
{
  compiledPattern = compile(pattern);
  this.pattern = pattern;
}

代码示例来源:origin: stackoverflow.com

java.lang.IllegalArgumentException: Illegal pattern character 'O'
java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845)
java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659)

代码示例来源:origin: jtulach/bck2brwsr

private void initialize(Locale loc) {
  // Verify and compile the given pattern.
  compiledPattern = compile(pattern);
  /* try the cache first */
  numberFormat = cachedNumberFormatData.get(loc);
  if (numberFormat == null) { /* cache miss */
    numberFormat = NumberFormat.getIntegerInstance(loc);
    numberFormat.setGroupingUsed(false);
    /* update cache */
    cachedNumberFormatData.putIfAbsent(loc, numberFormat);
  }
  numberFormat = (NumberFormat) numberFormat.clone();
  initializeDefaultCentury();
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

private void initialize(Locale loc) {
  // Verify and compile the given pattern.
  compiledPattern = compile(pattern);
  /* try the cache first */
  numberFormat = cachedNumberFormatData.get(loc);
  if (numberFormat == null) { /* cache miss */
    numberFormat = NumberFormat.getIntegerInstance(loc);
    numberFormat.setGroupingUsed(false);
    /* update cache */
    cachedNumberFormatData.putIfAbsent(loc, numberFormat);
  }
  numberFormat = (NumberFormat) numberFormat.clone();
  initializeDefaultCentury();
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Applies the given localized pattern string to this date format.
 *
 * @param pattern a String to be mapped to the new date and time format
 *        pattern for this format
 * @exception NullPointerException if the given pattern is null
 * @exception IllegalArgumentException if the given pattern is invalid
 */
public void applyLocalizedPattern(String pattern) {
   String p = translatePattern(pattern,
                 formatData.getLocalPatternChars(),
                 DateFormatSymbols.patternChars);
   compiledPattern = compile(p);
   this.pattern = p;
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Applies the given localized pattern string to this date format.
 *
 * @param pattern a String to be mapped to the new date and time format
 *        pattern for this format
 * @exception NullPointerException if the given pattern is null
 * @exception IllegalArgumentException if the given pattern is invalid
 */
public void applyLocalizedPattern(String pattern) {
   String p = translatePattern(pattern,
                 formatData.getLocalPatternChars(),
                 DateFormatSymbols.patternChars);
   compiledPattern = compile(p);
   this.pattern = p;
}

代码示例来源:origin: jtulach/bck2brwsr

compiledPattern = compile(pattern);
} catch (Exception e) {
  throw new InvalidObjectException("invalid pattern");

代码示例来源:origin: org.apidesign.bck2brwsr/emul

compiledPattern = compile(pattern);
} catch (Exception e) {
  throw new InvalidObjectException("invalid pattern");

相关文章

SimpleDateFormat类方法