/* */ package com.nstc;
/* */
/* */ import com.nstc.util.ChineseFormat;
/* */ import java.io.PrintStream;
/* */ import java.io.UnsupportedEncodingException;
/* */ import java.text.DecimalFormat;
/* */ import java.text.NumberFormat;
/* */ import java.util.Calendar;
/* */ import java.util.Date;
/* */ import java.util.Vector;
/* */
/* */ /** @deprecated */
/* */ public class Text
/* */ {
/* */ public static Date addDay(Date d, int n)
/* */ {
/* 36 */ return dateAdd(d, 5, n);
/* */ }
/* */
/* */ public static Date addMonth(Date d, int n)
/* */ {
/* 53 */ return dateAdd(d, 2, n);
/* */ }
/* */
/* */ public static Date addYear(Date d, int n)
/* */ {
/* 70 */ return dateAdd(d, 1, n);
/* */ }
/* */
/* */ public static String ChnMnyWord(String Ch)
/* */ {
/* 75 */ String S = "闆跺9璐板弫鑲嗕紞闄嗘煉鎹岀帠";
/* 76 */ int L = 0;
/* 77 */ L = Integer.parseInt(Ch);
/* 78 */ return "闆跺9璐板弫鑲嗕紞闄嗘煉鎹岀帠".substring(L, L + 1);
/* */ }
/* */
/* */ public static String cString(String s)
/* */ {
/* 87 */ return cString(s, "ISO8859_1");
/* */ }
/* */
/* */ public static String cString(String s, String codeType)
/* */ {
/* 98 */ if (s == null)
/* */ {
/* 100 */ return "";
/* */ }
/* */ try
/* */ {
/* 104 */ return new String(s.getBytes(codeType));
/* */ }
/* */ catch (UnsupportedEncodingException e) {
/* */ }
/* 108 */ return s;
/* */ }
/* */
/* */ public static Date dateAdd(Date d, int mode, int n)
/* */ {
/* 126 */ Calendar cl = Calendar.getInstance();
/* 127 */ cl.setTime(d);
/* 128 */ cl.add(mode, n);
/* 129 */ return cl.getTime();
/* */ }
/* */
/* */ public static int dateDiff(Date d1, Date d2)
/* */ {
/* 148 */ if (d1.after(d2))
/* */ {
/* 150 */ return (0 - dateDiff(d2, d1));
/* */ }
/* 152 */ Calendar c1 = Calendar.getInstance();
/* 153 */ Calendar c2 = Calendar.getInstance();
/* 154 */ c1.setTime(d1);
/* 155 */ c2.setTime(d2);
/* 156 */ int d = c2.get(6) - c1.get(6);
/* 157 */ int y1 = getYear(d1);
/* 158 */ int y2 = getYear(d2);
/* */
/* 160 */ while (y1 < y2)
/* */ {
/* 162 */ Date d0 = encodeDate(y1, 12, 31);
/* 163 */ c1.setTime(d0);
/* 164 */ d += c1.get(6);
/* 165 */ c1.add(1, 1);
/* 166 */ y1 = c1.get(1);
/* */ }
/* 168 */ return d;
/* */ }
/* */
/* */ public static String enclose(Calendar d)
/* */ {
/* 173 */ if ((d == null) || (d.getTime() == null))
/* */ {
/* 175 */ return null;
/* */ }
/* 177 */ return enclose(d.getTime());
/* */ }
/* */
/* */ public static String enclose(Date d)
/* */ {
/* 186 */ if (d == null)
/* */ {
/* 188 */ return null;
/* */ }
/* */
/* 192 */ return "'" + fmtString(d) + "'";
/* */ }
/* */
/* */ public static String enclose(String s)
/* */ {
/* 212 */ if (s == null)
/* */ {
/* 214 */ return null;
/* */ }
/* */
/* 218 */ return "'" + s + "'";
/* */ }
/* */
/* */ public static String enclose_todate(Calendar d)
/* */ {
/* 224 */ if ((d == null) || (d.getTime() == null))
/* */ {
/* 226 */ return null;
/* */ }
/* 228 */ return enclose_todate(d.getTime());
/* */ }
/* */
/* */ public static String enclose_todate(Date d)
/* */ {
/* 233 */ if (d == null)
/* */ {
/* 235 */ return null;
/* */ }
/* */
/* 239 */ return "to_date('" + fmtString(d) + "','YYYY-MM-DD')";
/* */ }
/* */
/* */ public static Date encodeDate(int y, int m, int d)
/* */ {
/* 257 */ Calendar cl = Calendar.getInstance();
/* 258 */ cl.set(1, y);
/* 259 */ cl.set(2, m - 1);
/* 260 */ cl.set(5, d);
/* 261 */ cl.set(10, 0);
/* 262 */ cl.set(11, 0);
/* 263 */ cl.set(12, 0);
/* 264 */ cl.set(13, 0);
/* 265 */ cl.set(14, 0);
/* 266 */ return cl.getTime();
/* */ }
/* */
/* */ public static String fmtAmount(double val)
/* */ {
/* 285 */ String fmtStr = "prcsn=17|scl=2|sprtr=|zr=0|prfx=";
/* 286 */ return fmtString(val, fmtStr);
/* */ }
/* */
/* */ public static String fmtDateTime(Calendar d)
/* */ {
/* 291 */ if ((d == null) || (d.getTime() == null))
/* */ {
/* 293 */ return null;
/* */ }
/* 295 */ return fmtDateTime(d.getTime());
/* */ }
/* */
/* */ public static String fmtDateTime(Date d)
/* */ {
/* 314 */ if (d == null)
/* */ {
/* 316 */ return null;
/* */ }
/* 318 */ Calendar cl = Calendar.getInstance();
/* 319 */ cl.setTime(d);
/* 320 */ String year = cl.get(1) + "";
/* 321 */ String month = (101 + cl.get(2)) + "";
/* 322 */ month = month.substring(1);
/* 323 */ String day = (100 + cl.get(5)) + "";
/* 324 */ day = day.substring(1);
/* 325 */ String h = (cl.get(11) + 100) + "";
/* 326 */ String m = (cl.get(12) + 100) + "";
/* 327 */ String s = (cl.get(13) + 100) + "";
/* */
/* 329 */ return year + "-" + month + "-" + day + " " + h.substring(1) + ":" + m.substring(1) + ":" + s.substring(1);
/* */ }
/* */
/* */ public static String fmtInteger(long n, int zerolen)
/* */ {
/* 350 */ if (n == 0L)
/* */ {
/* 352 */ return "";
/* */ }
/* 354 */ String s = Long.toString(100000000000L + n);
/* 355 */ if (s.length() > zerolen)
/* */ {
/* 357 */ return s.substring(s.length() - zerolen);
/* */ }
/* 359 */ return n + "";
/* */ }
/* */
/* */ public static String fmtString(double val)
/* */ {
/* 378 */ String fmtStr = "prcsn=15|scl=2|sprtr=,|zr=|prfx=";
/* 379 */ return fmtString(val, fmtStr);
/* */ }
/* */
/* */ public static String fmtString(double val, String fmtStr)
/* */ {
/* 399 */ int i = 0; int j = 0; int k = 0; int l = 0;
/* 400 */ int scl = 2;
/* 401 */ String sprtr = ","; String zr = ""; String prfx = "$";
/* 402 */ String upperFmtStr = fmtStr.toUpperCase();
/* 403 */ String valStr = ""; String sResult = ""; String s = "";
/* 404 */ double minVal = 0.01D;
/* */
/* 406 */ l = fmtStr.length();
/* 407 */ i = upperFmtStr.indexOf("PRCSN=");
/* 408 */ if (i >= 0)
/* */ {
/* 410 */ i += 6;
/* 411 */ j = upperFmtStr.indexOf("|", i);
/* 412 */ if (j < i)
/* */ {
/* 414 */ j = l;
/* */ }
/* */ }
/* */
/* 418 */ i = upperFmtStr.indexOf("SCL=");
/* 419 */ if (i >= 0)
/* */ {
/* 421 */ i += 4;
/* 422 */ j = upperFmtStr.indexOf("|", i);
/* 423 */ if (j < i)
/* */ {
/* 425 */ j = l;
/* */ }
/* 427 */ scl = Integer.parseInt(fmtStr.substring(i, j), 10);
/* */ }
/* 429 */ i = upperFmtStr.indexOf("SPRTR=");
/* 430 */ if (i >= 0)
/* */ {
/* 432 */ i += 6;
/* 433 */ j = upperFmtStr.indexOf("|", i);
/* 434 */ if (j < i)
/* */ {
/* 436 */ j = l;
/* */ }
/* 438 */ sprtr = fmtStr.substring(i, j);
/* */ }
/* 440 */ i = upperFmtStr.indexOf("ZR=");
/* 441 */ if (i >= 0)
/* */ {
/* 443 */ i += 3;
/* 444 */ j = upperFmtStr.indexOf("|", i);
/* 445 */ if (j < i)
/* */ {
/* 447 */ j = l;
/* */ }
/* 449 */ zr = fmtStr.substring(i, j);
/* */ }
/* 451 */ i = upperFmtStr.indexOf("PRFX=");
/* 452 */ if (i >= 0)
/* */ {
/* 454 */ i += 5;
/* 455 */ j = upperFmtStr.indexOf("|", i);
/* 456 */ if (j < i)
/* */ {
/* 458 */ j = l;
/* */ }
/* 460 */ prfx = fmtStr.substring(i, j);
/* */ }
/* */
/* 464 */ minVal = Math.pow(10.0D, -scl);
/* 465 */ if (Math.abs(val) < minVal)
/* */ {
/* 467 */ return zr;
/* */ }
/* */
/* 470 */ if (val < 0.0D)
/* */ {
/* 472 */ prfx = "-" + prfx;
/* 473 */ val = Math.abs(val);
/* */ }
/* */
/* 476 */ val += minVal * 0.5D;
/* 477 */ s = String.valueOf(val);
/* 478 */ s = s.toUpperCase();
/* */
/* 480 */ i = s.indexOf("E");
/* 481 */ if (i >= 0)
/* */ {
/* 483 */ j = Integer.parseInt(s.substring(i + 1, s.length()), 10);
/* 484 */ s = s.substring(0, i);
/* 485 */ i = s.indexOf(46);
/* 486 */ if (i >= 0)
/* */ {
/* 488 */ valStr = s.substring(0, i);
/* 489 */ l = s.length();
/* 490 */ for (k = 0; k < j - (l - 1 - i); ++k)
/* */ {
/* 492 */ s = s + "0";
/* */ }
/* 494 */ valStr = valStr + s.substring(i + 1, i + 1 + j) + ".";
/* 495 */ valStr = valStr + s.substring(i + 1 + j, l); break label593:
/* */ }
/* */
/* 499 */ valStr = s;
/* 500 */ for (k = 0; ; ++k) { if (k >= j)
/* */ break label593;
/* 502 */ valStr = valStr + "0";
/* */ }
/* */
/* */ }
/* */
/* 508 */ valStr = s;
/* */
/* 512 */ label593: i = valStr.indexOf(46);
/* 513 */ if (i > 0)
/* */ {
/* 515 */ if (scl > 0)
/* */ {
/* 517 */ sResult = valStr.substring(i, i + 1 + scl);
/* */ }
/* */ }
/* */ else
/* */ {
/* 522 */ i = valStr.length();
/* 523 */ if (scl > 0)
/* */ {
/* 525 */ sResult = ".";
/* 526 */ for (k = 0; k < scl; ++k)
/* */ {
/* 528 */ sResult = sResult + "0";
/* */ }
/* */ }
/* */
/* */ }
/* */
/* 534 */ i -= 1;
/* 535 */ j = 0;
/* */ do
/* */ {
/* 538 */ if (j++ == 3)
/* */ {
/* 540 */ j = 1;
/* 541 */ sResult = sprtr + sResult;
/* */ }
/* 543 */ sResult = valStr.substring(i, i + 1) + sResult;
/* 544 */ --i;
/* */ }
/* 546 */ while (i >= 0);
/* */
/* 548 */ sResult = prfx + sResult;
/* */
/* 550 */ return sResult;
/* */ }
/* */
/* */ public static String fmtString(Calendar d)
/* */ {
/* 555 */ if ((d == null) || (d.getTime() == null))
/* */ {
/* 557 */ return "";
/* */ }
/* 559 */ return fmtString(d.getTime());
/* */ }
/* */
/* */ public static String fmtString(Date d)
/* */ {
/* 578 */ if (d == null)
/* */ {
/* 580 */ return "";
/* */ }
/* */ try
/* */ {
/* 584 */ Calendar cl = Calendar.getInstance();
/* 585 */ cl.setTime(d);
/* 586 */ String year = cl.get(1) + "";
/* 587 */ String month = (101 + cl.get(2)) + "";
/* 588 */ month = month.substring(1);
/* 589 */ String day = (100 + cl.get(5)) + "";
/* 590 */ day = day.substring(1);
/* 591 */ return year + "-" + month + "-" + day;
/* */ }
/* */ catch (Exception e) {
/* */ }
/* 595 */ return "";
/* */ }
/* */
/* */ public static String fmtString(long val)
/* */ {
/* 615 */ String fmtStr = "prcsn=15|scl=0|sprtr=,|zr=|prfx=";
/* 616 */ return fmtString(val, fmtStr);
/* */ }
/* */
/* */ public static String fmtString(long val, String fmtStr)
/* */ {
/* 645 */ double dVal = Double.parseDouble(String.valueOf(val));
/* 646 */ return fmtString(dVal, fmtStr);
/* */ }
/* */
/* */ public static String fmtString(String val)
/* */ {
/* 665 */ String fmtStr = "prcsn=15|scl=2|sprtr=,|zr=|prfx=";
/* 666 */ return fmtString(val, fmtStr);
/* */ }
/* */
/* */ public static String fmtString(String val, String fmtStr)
/* */ {
/* 685 */ double dVal = Double.parseDouble(val);
/* 686 */ return fmtString(dVal, fmtStr);
/* */ }
/* */
/* */ public static String formatCurrency(double amount)
/* */ {
/* 699 */ String ret = formatCurrency0(amount);
/* 700 */ if (ret.equals("0.00"))
/* */ {
/* 702 */ ret = "";
/* */ }
/* 704 */ return ret;
/* */ }
/* */
/* */ public static String formatCurrency0(double amount)
/* */ {
/* 717 */ String pattern = "#,###,###,###,##0.00";
/* 718 */ String ret = formatNumber(amount, pattern);
/* 719 */ return ret;
/* */ }
/* */
/* */ public static String formatDate(Calendar date)
/* */ {
/* 734 */ if ((date == null) || (date.getTime() == null))
/* */ {
/* 736 */ return null;
/* */ }
/* 738 */ return formatDate(date.getTime(), "-");
/* */ }
/* */
/* */ public static String formatDate(Date date)
/* */ {
/* 753 */ return formatDate(date, "-");
/* */ }
/* */
/* */ public static String formatDate(Date date, String delimiter)
/* */ {
/* 766 */ if (date == null)
/* */ {
/* 768 */ return null;
/* */ }
/* 770 */ Calendar cl = Calendar.getInstance();
/* 771 */ cl.setTime(date);
/* 772 */ String year = cl.get(1) + "";
/* 773 */ String month = (101 + cl.get(2)) + "";
/* 774 */ month = month.substring(1);
/* 775 */ String day = (100 + cl.get(5)) + "";
/* 776 */ day = day.substring(1);
/* 777 */ return year + delimiter + month + delimiter + day;
/* */ }
/* */
/* */ public static String formatDateTime(Date date)
/* */ {
/* 790 */ if (date == null)
/* */ {
/* 792 */ return null;
/* */ }
/* 794 */ Calendar cl = Calendar.getInstance();
/* 795 */ cl.setTime(date);
/* 796 */ String year = cl.get(1) + "";
/* 797 */ String month = (101 + cl.get(2)) + "";
/* 798 */ month = month.substring(1);
/* 799 */ String day = (100 + cl.get(5)) + "";
/* 800 */ day = day.substring(1);
/* 801 */ String h = (cl.get(11) + 100) + "";
/* 802 */ String m = (cl.get(12) + 100) + "";
/* 803 */ String s = (cl.get(13) + 100) + "";
/* */
/* 805 */ return year + "-" + month + "-" + day + " " + h.substring(1) + ":" + m.substring(1) + ":" + s.substring(1);
/* */ }
/* */
/* */ public static String formatInteger(int n)
/* */ {
/* 820 */ return formatNumber(n, "00000000");
/* */ }
/* */
/* */ public static String formatInteger(int n, String pattern)
/* */ {
/* 825 */ return formatNumber(n, pattern);
/* */ }
/* */
/* */ public static String formatLongDate(Calendar date)
/* */ {
/* 830 */ if ((date == null) || (date.getTime() == null))
/* */ {
/* 832 */ return null;
/* */ }
/* 834 */ return formatLongDate(date.getTime());
/* */ }
/* */
/* */ public static String formatLongDate(Date date)
/* */ {
/* 847 */ if (date == null)
/* */ {
/* 849 */ return null;
/* */ }
/* 851 */ Calendar cl = Calendar.getInstance();
/* 852 */ cl.setTime(date);
/* 853 */ String year = cl.get(1) + "";
/* 854 */ String month = (101 + cl.get(2)) + "";
/* 855 */ month = month.substring(1);
/* 856 */ String day = (100 + cl.get(5)) + "";
/* 857 */ day = day.substring(1);
/* 858 */ return year + "骞�" + month + "鏈�" + day + "鏃�";
/* */ }
/* */
/* */ public static String formatNumber(double amount, String pattern)
/* */ {
/* 866 */ NumberFormat nf = NumberFormat.getCurrencyInstance();
/* 867 */ DecimalFormat df = (DecimalFormat)nf;
/* 868 */ df.setDecimalSeparatorAlwaysShown(true);
/* 869 */ df.applyPattern(pattern);
/* 870 */ return df.format(amount);
/* */ }
/* */
/* */ public static String formatPlainCurrency(double amount)
/* */ {
/* 883 */ String pattern = "############0.00";
/* 884 */ String ret = formatNumber(amount, pattern);
/* 885 */ return ret;
/* */ }
/* */
/* */ public static Date getBareDate(String s)
/* */ {
/* 904 */ if (s == null)
/* */ {
/* 906 */ return null;
/* */ }
/* 908 */ String date = s.substring(0, 4) + "-" + s.substring(4, 6) + "-" + s.substring(6);
/* 909 */ return getDate(date);
/* */ }
/* */
/* */ public static Calendar getCalendar()
/* */ {
/* 914 */ Calendar ret = Calendar.getInstance();
/* 915 */ ret.setTime(getDate());
/* 916 */ return ret;
/* */ }
/* */
/* */ public static Calendar getCalendar(Date date)
/* */ {
/* 921 */ if (date == null)
/* */ {
/* 923 */ return null;
/* */ }
/* 925 */ Calendar cl = Calendar.getInstance();
/* 926 */ cl.setTime(date);
/* 927 */ return cl;
/* */ }
/* */
/* */ public static Calendar getCalendar(String s)
/* */ {
/* 932 */ return getCalendar(getDate(s));
/* */ }
/* */
/* */ public static Calendar getCalendarTime(String s)
/* */ {
/* 937 */ return getCalendar(getDateTime(s));
/* */ }
/* */
/* */ public static String getChinaVal(double val)
/* */ {
/* 947 */ return ChineseFormat.formatCurrency(val);
/* */ }
/* */
/* */ public static String getChineseDate(Date d)
/* */ {
/* 964 */ Calendar cl = Calendar.getInstance();
/* 965 */ cl.setTime(d);
/* 966 */ return cl.get(1) + "骞�" + (1 + cl.get(2)) + "鏈�" + cl.get(5) + "鏃�";
/* */ }
/* */
/* */ public static String getCNWeekDay(Date d)
/* */ {
/* 983 */ String[] dWeek = { "鏃�", "涓�", "浜�", "涓�", "鍥�", "浜�", "鍏�" };
/* 984 */ Calendar cl = Calendar.getInstance();
/* 985 */ cl.setTime(d);
/* 986 */ int dDay = cl.get(7);
/* 987 */ return dWeek[dDay];
/* */ }
/* */
/* */ public static String getCurDate()
/* */ {
/* 1006 */ Date d = new Date();
/* 1007 */ return fmtString(d);
/* */ }
/* */
/* */ public static String getCurMonthEnd()
/* */ {
/* 1026 */ return fmtString(getMonthEnd(new Date()));
/* */ }
/* */
/* */ public static String getCurMonthFirst()
/* */ {
/* 1045 */ return fmtString(getMonthFirst(new Date()));
/* */ }
/* */
/* */ public static Date getDate()
/* */ {
/* 1064 */ return getDate(new Date());
/* */ }
/* */
/* */ public static Date getDate(Date date)
/* */ {
/* 1083 */ Calendar cl = Calendar.getInstance();
/* 1084 */ cl.setTime(date);
/* 1085 */ cl.set(10, 0);
/* 1086 */ cl.set(11, 0);
/* 1087 */ cl.set(12, 0);
/* 1088 */ cl.set(13, 0);
/* 1089 */ cl.set(14, 0);
/* 1090 */ return cl.getTime();
/* */ }
/* */
/* */ public static Date getDate(String s)
/* */ {
/* 1109 */ if (s == null)
/* */ {
/* 1111 */ return null;
/* */ }
/* */ try
/* */ {
/* 1115 */ int loc3 = s.indexOf(" ");
/* 1116 */ if (loc3 > 0)
/* */ {
/* 1118 */ s = s.substring(0, loc3);
/* */ }
/* 1120 */ int loc1 = 0;
/* 1121 */ int loc2 = s.indexOf("-");
/* 1122 */ int y = Integer.parseInt(s.substring(loc1, loc2));
/* 1123 */ loc1 = s.indexOf("-", loc2);
/* 1124 */ loc2 = s.indexOf("-", loc1 + 1);
/* 1125 */ int m = Integer.parseInt(s.substring(loc1 + 1, loc2));
/* 1126 */ int d = Integer.parseInt(s.substring(loc2 + 1));
/* 1127 */ return encodeDate(y, m, d);
/* */ }
/* */ catch (Exception e)
/* */ {
/* 1131 */ System.out.println(s + ":" + e.getMessage());
/* 1132 */ e.printStackTrace(); }
/* 1133 */ return null;
/* */ }
/* */
/* */ public static String getDateString8(Date d)
/* */ {
/* */ try
/* */ {
/* 1153 */ Calendar cl = Calendar.getInstance();
/* 1154 */ cl.setTime(d);
/* 1155 */ String year = cl.get(1) + "";
/* 1156 */ String month = (101 + cl.get(2)) + "";
/* 1157 */ month = month.substring(1);
/* 1158 */ String day = (100 + cl.get(5)) + "";
/* 1159 */ day = day.substring(1);
/* 1160 */ return year + month + day;
/* */ }
/* */ catch (Exception e) {
/* */ }
/* 1164 */ return "";
/* */ }
/* */
/* */ public static Date getDateTime(String s)
/* */ {
/* 1184 */ if (s == null)
/* */ {
/* 1186 */ return null;
/* */ }
/* 1188 */ if (s.length() < 8)
/* */ {
/* 1190 */ return null;
/* */ }
/* 1192 */ String datestr = new String(s);
/* */ try
/* */ {
/* 1195 */ String stime = "";
/* 1196 */ int loc3 = s.indexOf(" ");
/* 1197 */ if (loc3 > 0)
/* */ {
/* 1199 */ stime = s.substring(loc3 + 1);
/* 1200 */ s = s.substring(0, loc3);
/* */ }
/* */
/* 1203 */ int loc1 = 0;
/* 1204 */ int loc2 = s.indexOf("-");
/* 1205 */ int y = Integer.parseInt(s.substring(loc1, loc2));
/* 1206 */ loc1 = s.indexOf("-", loc2);
/* 1207 */ loc2 = s.indexOf("-", loc1 + 1);
/* 1208 */ int m = Integer.parseInt(s.substring(loc1 + 1, loc2));
/* 1209 */ int d = Integer.parseInt(s.substring(loc2 + 1));
/* 1210 */ int h = 0;
/* 1211 */ int min = 0;
/* 1212 */ int sec = 0;
/* */
/* 1214 */ loc1 = stime.indexOf(":");
/* 1215 */ if (loc1 > 0)
/* */ {
/* 1217 */ h = Integer.parseInt(stime.substring(0, loc1));
/* 1218 */ loc2 = stime.indexOf(":", loc1 + 1);
/* 1219 */ min = Integer.parseInt(stime.substring(loc1 + 1, loc2));
/* 1220 */ loc1 = stime.indexOf(":", loc2);
/* 1221 */ loc2 = stime.indexOf(".");
/* 1222 */ String secStr = (loc2 > 0) ? stime.substring(loc1 + 1, loc2) : stime.substring(loc1 + 1);
/* 1223 */ sec = Integer.parseInt(secStr);
/* */ }
/* 1225 */ Calendar cl = Calendar.getInstance();
/* 1226 */ cl.set(y, m - 1, d, h, min, sec);
/* 1227 */ return cl.getTime();
/* */ }
/* */ catch (Exception e)
/* */ {
/* 1231 */ System.out.println("鏃ユ湡鏃堕棿鏍煎紡閿欒锛�" + datestr + " -- " + e.getMessage());
/* 1232 */ e.printStackTrace(); }
/* 1233 */ return null;
/* */ }
/* */
/* */ public static int getDay(Date d)
/* */ {
/* 1251 */ Calendar cl = Calendar.getInstance();
/* 1252 */ cl.setTime(d);
/* 1253 */ return cl.get(5);
/* */ }
/* */
/* */ public static String getENWeekDay(Date d)
/* */ {
/* 1270 */ String[] dWeek = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thurs", "Friday", "Saturday" };
/* 1271 */ Calendar cl = Calendar.getInstance();
/* 1272 */ cl.setTime(d);
/* 1273 */ int dDay = cl.get(7);
/* 1274 */ return dWeek[dDay];
/* */ }
/* */
/* */ public static long getIdentityByTime(Date d)
/* */ {
/* 1291 */ if (d == null)
/* */ {
/* 1293 */ d = new Date();
/* */ }
/* 1295 */ Calendar cl = Calendar.getInstance();
/* 1296 */ cl.setTime(d);
/* 1297 */ int year = cl.get(1) - 2000;
/* 1298 */ int h = cl.get(11);
/* 1299 */ int m = cl.get(12);
/* 1300 */ int s = cl.get(13);
/* 1301 */ int day = cl.get(6) + year * 366;
/* 1302 */ int sec = s + m * 60 + h * 3600;
/* 1303 */ return (day * 86400 + sec);
/* */ }
/* */
/* */ public static String getIndexVal(double val, int i)
/* */ {
/* 1311 */ NumberFormat nf = NumberFormat.getCurrencyInstance();
/* 1312 */ DecimalFormat df = (DecimalFormat)nf;
/* 1313 */ df.setDecimalSeparatorAlwaysShown(true);
/* 1314 */ df.applyPattern("##############0.00");
/* 1315 */ String text = df.format(val);
/* 1316 */ int point = text.indexOf(".");
/* 1317 */ int index = point - i;
/* 1318 */ String ret = "";
/* 1319 */ if (index == -1)
/* */ {
/* 1321 */ ret = "锟�";
/* */ }
/* 1323 */ else if ((index >= 0) && (index < text.length()))
/* */ {
/* 1325 */ ret = text.substring(index, index + 1);
/* */ }
/* 1327 */ return ret;
/* */ }
/* */
/* */ public static int getMonth(Date d)
/* */ {
/* 1344 */ Calendar cl = Calendar.getInstance();
/* 1345 */ cl.setTime(d);
/* 1346 */ return (cl.get(2) + 1);
/* */ }
/* */
/* */ public static Date getMonthEnd(Date date)
/* */ {
/* 1363 */ Date d = getMonthFirst(date);
/* 1364 */ d = addMonth(d, 1);
/* 1365 */ d = addDay(d, -1);
/* 1366 */ return d;
/* */ }
/* */
/* */ public static Date getMonthFirst(Date date)
/* */ {
/* 1383 */ Calendar cl = Calendar.getInstance();
/* 1384 */ cl.setTime(date);
/* 1385 */ int y = cl.get(1);
/* 1386 */ int m = cl.get(2) + 1;
/* 1387 */ return encodeDate(y, m, 1);
/* */ }
/* */
/* */ public static String getNumberString(String s)
/* */ {
/* 1419 */ String num = "0123456789-.";
/* 1420 */ String ret = "";
/* 1421 */ if (s != null)
/* */ {
/* 1423 */ for (int i = 0; i < s.length(); ++i)
/* */ {
/* 1425 */ String ch = s.charAt(i) + "";
/* 1426 */ if (num.indexOf(ch) < 0)
/* */ continue;
/* 1428 */ ret = ret + ch;
/* */ }
/* */ }
/* */
/* 1432 */ return ret;
/* */ }
/* */
/* */ public static String getPrintable(byte[] b)
/* */ {
/* 1437 */ StringBuffer ret = new StringBuffer();
/* 1438 */ for (int i = 0; i < b.length; ++i)
/* */ {
/* 1440 */ int v = b[i] & 0xFF;
/* 1441 */ if (v < 16)
/* */ {
/* 1443 */ ret.append('0');
/* */ }
/* 1445 */ ret.append(Integer.toString(v, 16).toUpperCase());
/* */ }
/* 1447 */ return new String(ret);
/* */ }
/* */
/* */ public static String[] getStringArray(String s)
/* */ {
/* 1452 */ return getStringArray(s, ",");
/* */ }
/* */
/* */ public static String[] getStringArray(String s, String delimiter)
/* */ {
/* 1457 */ Vector v = new Vector();
/* 1458 */ int loc = 0;
/* 1459 */ int n = s.length();
/* 1460 */ while (loc < n)
/* */ {
/* 1462 */ int pos = s.indexOf(delimiter, loc);
/* 1463 */ if (pos < 0)
/* 1464 */ pos = n;
/* 1465 */ String ss = s.substring(loc, pos);
/* 1466 */ v.add(ss);
/* 1467 */ loc = pos + delimiter.length();
/* */ }
/* 1469 */ String[] ret = new String[v.size()];
/* 1470 */ v.copyInto(ret);
/* 1471 */ return ret;
/* */ }
/* */
/* */ public static String getTimeString6(Date d)
/* */ {
/* 1488 */ Calendar cl = Calendar.getInstance();
/* 1489 */ cl.setTime(d);
/* 1490 */ String h = (cl.get(11) + 100) + "";
/* 1491 */ String m = (cl.get(12) + 100) + "";
/* 1492 */ String s = (cl.get(13) + 100) + "";
/* 1493 */ return h.substring(1) + m.substring(1) + s.substring(1);
/* */ }
/* */
/* */ public static String getToken(String s, int loc, char token)
/* */ {
/* 1512 */ int i = 0; int n1 = 0; int n2 = 0; int l = 0; int times = 0;
/* 1513 */ String sResult = "";
/* */
/* 1515 */ l = s.length();
/* 1516 */ if (loc < 1)
/* */ {
/* 1518 */ return sResult;
/* */ }
/* */
/* 1521 */ times = 0;
/* 1522 */ n1 = 0;
/* 1523 */ n2 = l;
/* 1524 */ for (i = 0; i < l; ++i)
/* */ {
/* 1526 */ if (s.charAt(i) != token)
/* */ continue;
/* 1528 */ ++times;
/* 1529 */ if (times == loc - 1)
/* */ {
/* 1531 */ n1 = i + 1;
/* */ }
/* 1533 */ if (times != loc)
/* */ continue;
/* 1535 */ n2 = i;
/* */ }
/* */
/* 1539 */ if (times < loc - 1)
/* */ {
/* 1541 */ sResult = "";
/* */ }
/* */ else
/* */ {
/* 1545 */ sResult = s.substring(n1, n2);
/* */ }
/* 1547 */ return sResult;
/* */ }
/* */
/* */ public static int getYear(Date d)
/* */ {
/* 1564 */ Calendar cl = Calendar.getInstance();
/* 1565 */ cl.setTime(d);
/* 1566 */ return cl.get(1);
/* */ }
/* */
/* */ public static boolean javaVersionHigherThan(String v)
/* */ {
/* 1571 */ String jvm_version = System.getProperty("java.version");
/* 1572 */ return (jvm_version.compareTo(v) > 0);
/* */ }
/* */
/* */ public static long longAmount(double v)
/* */ {
/* 1589 */ Double amt = new Double(v * 100.0D);
/* 1590 */ long n = Math.round(amt.doubleValue());
/* 1591 */ return n;
/* */ }
/* */
/* */ public static String makeStringByDate(Date d)
/* */ {
/* 1608 */ if (d == null)
/* */ {
/* 1610 */ d = new Date();
/* */ }
/* 1612 */ Calendar cl = Calendar.getInstance();
/* 1613 */ cl.setTime(d);
/* 1614 */ String year = cl.get(1) + "";
/* 1615 */ String month = (101 + cl.get(2)) + "";
/* 1616 */ month = month.substring(1);
/* 1617 */ String day = (100 + cl.get(5)) + "";
/* 1618 */ day = day.substring(1);
/* */
/* 1620 */ return year + month + day;
/* */ }
/* */
/* */ public static String makeStringByDateTime(Date d)
/* */ {
/* 1637 */ if (d == null)
/* */ {
/* 1639 */ d = new Date();
/* */ }
/* 1641 */ Calendar cl = Calendar.getInstance();
/* 1642 */ cl.setTime(d);
/* 1643 */ String year = cl.get(1) + "";
/* 1644 */ String month = (101 + cl.get(2)) + "";
/* 1645 */ month = month.substring(1);
/* 1646 */ String day = (100 + cl.get(5)) + "";
/* 1647 */ day = day.substring(1);
/* 1648 */ String h = (cl.get(11) + 100) + "";
/* 1649 */ String m = (cl.get(12) + 100) + "";
/* 1650 */ String s = (cl.get(13) + 100) + "";
/* 1651 */ String ms = (cl.get(14) + 1000) + "";
/* */
/* 1653 */ return year + month + day + "_" + h.substring(1) + "" + m.substring(1) + "" + s.substring(1) + "." + ms.substring(1);
/* */ }
/* */
/* */ public static String nullString(Object o)
/* */ {
/* 1662 */ return nullString(o, "");
/* */ }
/* */
/* */ public static String nullString(Object o, String nullStr)
/* */ {
/* 1671 */ if (o == null)
/* */ {
/* 1673 */ return nullStr;
/* */ }
/* 1675 */ String ret = o.toString();
/* 1676 */ if (ret.length() < 1)
/* */ {
/* 1678 */ ret = nullStr;
/* */ }
/* 1680 */ return ret;
/* */ }
/* */
/* */ public static double parseDouble(String numberString)
/* */ {
/* */ try
/* */ {
/* 1697 */ double amount = Double.parseDouble(getNumberString(numberString));
/* 1698 */ return amount;
/* */ }
/* */ catch (Exception e) {
/* */ }
/* 1702 */ return 0.0D;
/* */ }
/* */
/* */ public static int parseInt(String s)
/* */ {
/* 1717 */ if (s == null)
/* */ {
/* 1719 */ return 0;
/* */ }
/* 1721 */ String v = "";
/* 1722 */ String num = "0123456789-";
/* 1723 */ for (int i = 0; i < s.length(); ++i)
/* */ {
/* 1725 */ String ch = s.charAt(i) + "";
/* 1726 */ if (num.indexOf(ch) < 0)
/* */ continue;
/* 1728 */ v = v + ch;
/* */ }
/* */
/* 1731 */ if (v.length() < 1)
/* */ {
/* 1733 */ return 0;
/* */ }
/* */
/* 1737 */ return Integer.parseInt(v);
/* */ }
/* */
/* */ public static double parseValue(String s)
/* */ {
/* 1751 */ if (s == null)
/* */ {
/* 1753 */ return 0.0D;
/* */ }
/* 1755 */ String v = "";
/* 1756 */ String num = "0123456789-.Ee";
/* 1757 */ for (int i = 0; i < s.length(); ++i)
/* */ {
/* 1759 */ String ch = s.charAt(i) + "";
/* 1760 */ if (num.indexOf(ch) < 0)
/* */ continue;
/* 1762 */ v = v + ch;
/* */ }
/* */
/* 1765 */ if (v.length() < 1)
/* */ {
/* 1767 */ return 0.0D;
/* */ }
/* */
/* 1771 */ return Double.parseDouble(v);
/* */ }
/* */
/* */ public static String replaceString(String s, String oldStr, String newStr)
/* */ {
/* 1783 */ int si = 0; int ei = 0;
/* 1784 */ if (newStr != null)
/* */ {
/* */ do
/* */ {
/* 1788 */ si = s.indexOf(oldStr, ei);
/* 1789 */ if (si < 0)
/* */ continue;
/* 1791 */ s = s.substring(0, si) + newStr + s.substring(si + oldStr.length());
/* 1792 */ ei = si + newStr.length();
/* */ }
/* */
/* 1795 */ while (si >= 0);
/* */ }
/* 1797 */ return s;
/* */ }
/* */
/* */ public static int secondDiff(Date d1, Date d2)
/* */ {
/* 1821 */ Calendar c1 = Calendar.getInstance();
/* 1822 */ Calendar c2 = Calendar.getInstance();
/* 1823 */ c1.setTime(d1);
/* 1824 */ c2.setTime(d2);
/* 1825 */ int d = c2.get(13) - c1.get(13);
/* 1826 */ return d;
/* */ }
/* */
/* */ public static String UTF8String(String s)
/* */ {
/* 1835 */ return cString(s, "UTF8");
/* */ }
/* */ }