timer.java

来自「javaservice在windows制作服务程序」· Java 代码 · 共 26 行

JAVA
26
字号
import java.util.*;import java.text.*;import java.io.*;import java.net.*;public class Timer implements Service {  public Timer() {  }  public void serve(InputStream in, OutputStream out) throws IOException {      String timeFormat = "yyyy-MM-dd hh:mm:ss";      SimpleDateFormat timeFormatter = new SimpleDateFormat(timeFormat);      BufferedReader from_client = new BufferedReader(new InputStreamReader(in));      PrintWriter outPrint = new PrintWriter(out);      String sDate = timeFormatter.format(new Date());      outPrint.println("当前时间是:" + sDate);      outPrint.flush();      try {      	from_client.close();      	outPrint.close();      }catch (Exception e){}  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?