我写了一个简单的代码,将常规日期转换为Julian日期.
以下是需要相同转换的代码:
public int convertToJulian(String unformattedDate)
{
/*Unformatted Date: ddmmyyyy*/
int resultJulian = 0;
if(unformattedDate.length() > 0)
{
/*Days of month*/
int[] monthValues = {31,28,31,30,31,30,31,31,30,31,30,31};
String dayS, monthS, yearS;
dayS = unformattedDate.substring(0,2);
monthS = unformattedDate.substring(3, 5);
yearS = unformattedDate.substring(6, 10);
/*Convert to Integer*/
int day = Integer.valueOf(dayS);
int month = Integer.valueOf(monthS);
int year = Integer.valueOf(yearS);
//Leap year check
if(year % 4 == 0)
{
monthValues[1] = 29;
}
//Start building Julian date
String julianDate = "1";
//last two digit of …Run Code Online (Sandbox Code Playgroud) 我正在尝试为企业系统编写集成.
有一个Web服务器正在被来自两个不同地方的许多客户使用.此服务器上安装了两台网络打印机.
我想要做的是将PDF文档打印到这些打印机.我希望程序将文档发送到请求它的打印机.
我可以确定请求的位置.但是,我无法在运行时设置默认打印机.
由于它是在后台运行的Web服务器,因此我无法填充打印机对话框并让用户选择打印机.我必须能够设置将以编程方式使用的打印机.
现在,PrinterJob.lookupPrintServices();我能够通过使用看到系统上注册的打印机 ,我可以使用请求的打印机设置服务,但不会更改默认打印机,系统会继续在默认打印机上打印.
请告诉我你如何实现它的想法.