/**
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;
}