細心!用心!耐心!

          吾非文人,乃市井一俗人也,讀百卷書,跨江河千里,故申城一游; 一兩滴辛酸,三四年學業,五六點粗墨,七八筆買賣,九十道人情。

          BlogJava 聯系 聚合 管理
            1 Posts :: 196 Stories :: 10 Comments :: 0 Trackbacks


          /**
             import com.lowagie.text.*;
             import com.lowagie.text.pdf.PdfWriter;
             import java.io.*;
             import java.text.*;
             文檔輸出
          */
          public static void billImagePdfGenerator(String pdfMsg, String brand, OutputStream output)
              {
                  Document document = new Document(PageSize.A4);
                  String tempStr = "";
                  try
                  {
                      PdfWriter.getInstance(document, output);
                      document.open();
                      Image jpg = Image.getInstance("emice/jsp/images/bi" + brand + ".jpg");
                      jpg.scalePercent(80F);
                      document.add(jpg);
                      BufferedReader reader = null;
                      reader = new BufferedReader(new StringReader(pdfMsg));
                      while((tempStr = reader.readLine()) != null)
                      {
                          if(tempStr.startsWith("Page  "))
                              document.newPage();
                          Phrase phrase = new Phrase(10F, tempStr + "\n", FontFactory.getFont("Courier", 9F));
                          document.add(phrase);
                      }
                      document.close();
                      reader.close();
                  }
                  catch(DocumentException de)
                  {
                      System.err.println(de.getMessage());
                  }
                  catch(IOException ioe)
                  {
                      System.err.println(ioe.getMessage());
                  }
              }
             
             
             
            /**
               獲取向前或者向后幾天的日期
            */
            public static final String getCaseFormatTime(int shiftDay)
              {
                  Calendar cal = Calendar.getInstance();
                  int year = cal.get(1);
                  int month = cal.get(2);
                  int date = cal.get(5);
                  int hour = cal.get(11);
                  int minute = cal.get(12);
                  int second = cal.get(13);
                  date += shiftDay;
                  cal.set(year, month, date, hour, minute, second);
                  Date d = cal.getTime();
                  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
                  String dateString = sdf.format(d);
                  return dateString;
              }
             
             
             
              /**
                獲取當前時間
              */
              public static final String getCurrentFormatDate()
              {
                  Date d = new Date();
                  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
                  String dateString = sdf.format(d);
                  return dateString;
              }
             
              /**
                獲取資源文件內容
                import org.apache.struts.util.MessageResources;
                import org.apache.struts.util.PropertyMessageResourcesFactory;
              */
              public static String getMessage(String resourceName, String messageName)
              {
                  MessageResources resource = (new PropertyMessageResourcesFactory()).createResources(resourceName);
                  String value = resource.getMessage(messageName);
                  if(value == null)
                      value = "";
                  return value;
              }

          posted on 2007-10-16 16:55 張金鵬 閱讀(318) 評論(0)  編輯  收藏 所屬分類: core java中的一些數據結構的處理
          主站蜘蛛池模板: 陕西省| 简阳市| 汝城县| 沽源县| 新河县| 丘北县| 武冈市| 五莲县| 鞍山市| 上思县| 阿克陶县| 固原市| 察雅县| 营口市| 泰宁县| 西昌市| 凉山| 丰原市| 临西县| 特克斯县| 巴林左旗| 集贤县| 宁乡县| 闽清县| 西丰县| 锡林浩特市| 金川县| 乳山市| 霍林郭勒市| 克什克腾旗| 临漳县| 乐都县| 甘南县| 弥勒县| 灵丘县| 安溪县| 玉溪市| 工布江达县| 闸北区| 南乐县| 洛阳市|