Here you can find the source of parseRegExcelNumber(String number)
private static String parseRegExcelNumber(String number)
//package com.java2s; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright 2013 Joseph Yuan/*from ww w .java2 s. com*/ * * 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 * * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static String parseRegExcelNumber(String number) { String today_d = formatToday("dd"), today_m = formatToday("MM"), today_y = formatToday("yyyy"); String regex = "(" + today_y.substring(0, 2) + ")?" + today_y.substring(2) + today_m + today_d; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(number); String buf = ""; if (m.find()) { if (m.group().length() == 6) { buf = (m.start() == 0 ? "" : "<NUMBER>") + "<DATE:TODAY:YYMMDD>" + (m.end() == number.length() ? "" : "<NUMBER>"); } else { buf = (m.start() == 0 ? "" : "<NUMBER>") + "<DATE:TODAY:YYYYMMDD>" + (m.end() == number.length() ? "" : "<NUMBER>"); } return buf; } String yesterday_d = formatYesterday("dd"), yesterday_m = formatYesterday("MM"), yesterday_y = formatYesterday("yyyy"); regex = "(" + yesterday_y.substring(0, 2) + ")?" + yesterday_y.substring(2) + yesterday_m + yesterday_d; p = Pattern.compile(regex); m = p.matcher(number); buf = ""; if (m.find()) { if (m.group().length() == 6) { buf = (m.start() == 0 ? "" : "<NUMBER>") + "<DATE:YESTERDAY:YYMMDD>" + (m.end() == number.length() ? "" : "<NUMBER>"); } else { buf = (m.start() == 0 ? "" : "<NUMBER>") + "<DATE:YESTERDAY:YYYYMMDD>" + (m.end() == number.length() ? "" : "<NUMBER>"); } return buf; } return "<NUMBER>"; } public static String formatToday() { return formatDate("MM.dd.yy", 0, 0, 0); } public static String formatToday(String format) { return formatDate(format, 0, 0, 0); } public static String formatYesterday() { return formatDate("MM.dd.yy", 0, 0, -1); } public static String formatYesterday(String format) { return formatDate(format, 0, 0, -1); } public static String formatDate(String format, int offset_years, int offset_months, int offset_days) { Calendar date = Calendar.getInstance(); date.add(Calendar.YEAR, offset_years); date.add(Calendar.MONTH, offset_months); date.add(Calendar.DATE, offset_days); return formatDate(format, date); } public static String formatDate(Calendar c) { return (new SimpleDateFormat("MM.dd.yy")).format(c.getTime()); } public static String formatDate(String format, Calendar c) { return (new SimpleDateFormat(format)).format(c.getTime()); } }