細心!用心!耐心!

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

          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 張金鵬 閱讀(316) 評論(0)  編輯  收藏 所屬分類: core java中的一些數據結構的處理
          主站蜘蛛池模板: 刚察县| 松潘县| 开远市| 湖北省| 历史| 闻喜县| 松原市| 辽源市| 平原县| 繁昌县| 长顺县| 界首市| 奎屯市| 上虞市| 高阳县| 光山县| 昭通市| 余庆县| 凤台县| 洛扎县| 井冈山市| 巴彦淖尔市| 旅游| 扬州市| 临清市| 濮阳县| 叙永县| 驻马店市| 宁夏| 抚顺市| 东乌珠穆沁旗| 桃源县| 开平市| 洪湖市| 定陶县| 昌图县| 宣武区| 阳信县| 游戏| 驻马店市| 霍邱县|