📄 timehandler.java
字号:
/**
* Created at Nov 10, 2008
*/
package com.jdev.net.event;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
/**
* <p>Title: TimeHandler</p>
* <p>Description: 时间查询服务器</p>
* @author Lawrence
* @version 1.0
*/
public class TimeHandler extends EventAdapter {
/* (non-Javadoc)
* @see com.jdev.net.event.EventAdapter#onWrite(com.jdev.net.event.Request, com.jdev.net.event.Response)
*/
@Override
public void onWrite(Request request, Response response) throws Exception {
String command = new String(request.getDataInput());
String time = null;
Date date = new Date();
// 判断查询命令
if (command.equals("GB")) {
// 中文格式
DateFormat cnDate = DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL, Locale.CHINA);
time = cnDate.format(date);
}
else {
// 英文格式
DateFormat enDate = DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL, Locale.US);
time = enDate.format(date);
}
response.send(time.getBytes());
}
/**
*
*/
public TimeHandler() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -