예제 #1
0
 /**
  * 截取字符串中的开始时间
  *
  * @param str
  * @return
  */
 public static String[] getYear(String str) {
   String[] year = null;
   if (str != null && str.trim().length() > 0) {
     String temp = "";
     int beginPos = 0; // 指针开始位置
     int endPos = 0; // 指针结束位置
     int movePos = 0; // 移动位置
     int flag = 0; // 标志一个数字的开始[1-开始 0-暂停开始]
     boolean find = false; // 标志是否找到年份数据
     boolean special = false; // 标志特殊年份(93年/02年)
     while (beginPos <= endPos && endPos < str.length() && movePos < str.length()) {
       if (Character.isDigit(str.charAt(movePos))) {
         if ((endPos - beginPos == 1) && (flag == 1)) {
           if (str.substring(endPos + 1, endPos + 2).equals("年")) {
             find = true;
             special = true;
             break;
           }
         }
         if ((endPos - beginPos == 3) && (flag == 1)) {
           find = true;
           break;
         }
         if (flag == 0) {
           flag = 1;
           beginPos = movePos; // 标志开始位置
         }
         movePos++;
         endPos++;
         continue;
       } else {
         if (flag == 1) { // 已经标志一个数字的开始
           flag = 0;
         }
         movePos++;
         endPos++;
       }
     }
     if (find) {
       if (special) {
         String tempStr = StringUtil.getSubStr(str, beginPos, endPos + 1);
         if (tempStr.startsWith("0")) {
           tempStr = "20" + tempStr;
         } else {
           tempStr = "19" + tempStr;
         }
         year = new String[3];
         year[0] = tempStr;
         year[1] = String.valueOf(beginPos);
         year[2] = String.valueOf(endPos);
       } else {
         year = new String[3];
         year[0] = StringUtil.getSubStr(str, beginPos, endPos + 1);
         year[1] = String.valueOf(beginPos);
         year[2] = String.valueOf(endPos);
       }
     }
   }
   return year;
 }
예제 #2
0
 /**
  * 处理一条基本的工作信息
  *
  * @param str
  * @return
  */
 public static String[] processWorkInfo(String str) {
   String[] info = null;
   try {
     if (str != null && !str.equals("")) {
       String[] tempYear = getYear(str);
       if (tempYear != null) {
         info = new String[5];
         info[0] = tempYear[0];
         String[] monthInfo = findMonth(str, Integer.parseInt(tempYear[2]));
         info[1] = monthInfo[0].equals("") ? "1" : monthInfo[0];
         str =
             StringUtil.getSubStr(
                 str,
                 monthInfo[1].equals("")
                     ? Integer.parseInt(tempYear[2]) + 1
                     : Integer.parseInt(monthInfo[1]),
                 str.length());
         String[] temp1Year = getYear(str);
         if (temp1Year != null) {
           info[2] = temp1Year[0];
           monthInfo = findMonth(str, Integer.parseInt(temp1Year[2]));
           info[3] = monthInfo[0].equals("") ? "9" : monthInfo[0];
           info[4] =
               StringUtil.getSubStr(
                   str,
                   monthInfo[1].equals("")
                       ? Integer.parseInt(temp1Year[2]) + 1
                       : Integer.parseInt(monthInfo[1]),
                   str.length());
         } else {
           info[2] = "2008";
           info[3] = "9";
           info[4] = str;
         }
         tempYear = null;
         temp1Year = null;
       } else {
         System.out.println("----没有找到年份数据,数据丢弃!");
       }
     }
   } catch (Exception e) {
     info = null;
     return info;
   }
   return info;
 }
예제 #3
0
 public static String[] analysisCity(String city) {
   String[] data = {"4500", "4500"};
   if (!"".equals(city)) {
     String cityCode = MapTable.getCodeTwo(city, MapTable.jobLocation);
     if (!"".equals(cityCode) && cityCode.length() == 4) {
       data[0] = StringUtil.getSubStr(cityCode, 0, 2) + "00";
       data[1] = cityCode;
     }
   }
   return data;
 }