JavaµÄʱ¼ä´¦Àí(Ðø)
¸ÅÊö
Èç¹ûÄãÖªµÀÔõÑùÔÚjavaÖÐʹÓÃÈÕÆÚ£¬ÄÇôʹÓÃʱ¼äºÍËü²Å²»¶àÒ»Ñù¼òµ¥¡£ÕâƪÎÄÕ¸æËßÄãÔõÑù°ÑËûÃǵIJî±ðÁªÏµÆðÀ´¡£Robert Nielsen»¹¸æËßÄãÔõÑùʹÓÃjavaÀ´¼ÆËãµÖ´ïº½°àºÍÖÆÔì¹ý³ÌµÄʱ¼ä¡£
×÷ÕߣºRobert Nielsen
·Ò룺Cocia Lin
ÕâƪÎÄÕÂÊÇÔÚÎÒ·¢±í¹ýµÄ<¼ÆËãJavaʱ¼ä>(ÒëÕß:ÒѾ·ÒëÍê³É)µÄ»ù´¡Éϵġ£ÔÚÕâÀÎÒÁгöÄÇƪÎÄÕ¼¸¸öÄãÓ¦¸ÃÊìϤµÃ¹Ø¼üµã¡£Èç¹ûÕ⼸µãÄ㲻̫Çå³þ£¬ÎÒ½¨ÒéÄã¶ÁÒ»ÏÂ<¼ÆËãJavaʱ¼ä>£¬Á˽âһϡ£
1. Java¼ÆËãʱ¼äÒÀ¿¿1970Äê1ÔÂ1ÈÕ¿ªÊ¼µÄºÁÃëÊý.
2. DateÀàµÄ¹¹Ô캯ÊýDate()·µ»Ø´ú±íµ±Ç°´´½¨µÄʱ¿ÌµÄ¶ÔÏó¡£DateµÄ·½·¨getTime()·µ»ØÒ»¸ölongÖµÔÚÊýÖµÉϵÈÓÚ1970Äê1ÔÂ1ÈÕ֮ǰ»òÖ®ºóµÄʱ¿Ì¡£
3. DateFormatÀàÓÃÀ´×ª»»Dateµ½String,·´Ö®ÒàÈ»¡£¾²Ì¬·½·¨getDateInstance()·µ»ØDateFormatµÄȱʡ¸ñʽ£»getDateInstance(DateFormat.FIELD)·µ»ØÖ¸¶¨µÄDateFormat¶ÔÏó¸ñʽ¡£Format(Date d)·½·¨·µ»ØString±íʾÈÕÆÚ£¬ÀýÈ磢January 1,2002.£¢·´¹ýÀ´£¬parse(String s)·½·¨·µ»ØÒÔ²ÎÊý×Ö·û´®±íʾµÄDate¶ÔÏó¡£
4. format()·½·¨·µ»ØµÄ×Ö·û´®¸ñʽ¸ù¾Ý²»Í¬µØÇøµÄʱ¼äÉèÖöøÓÐËù²»Í¬¡£
5. GregorianCalendearÀàÓÐÁ½¸öÖØÒªµÄ¹¹Ô캯Êý£ºGregorianCalerdar(),·µ»Ø´ú±íµ±Ç°´´½¨Ê±¼äµÄ¶ÔÏó£»GregorianCalendar(int year,int month,int date)·µ»Ø´ú±íÈÎÒâÈÕÆڵĶÔÏó¡£GregorianCalendarÀàµÄgetTime()·½·¨·µ»ØÈÕÆÚ¶ÔÏó¡£Add(int field,int amount)·½·¨Í¨¹ý¼Ó»ò¼õʱ¼äµ¥Î»£¬ÏóÌìÊý£¬ÔÂÊý»òÄêÊýÀ´¼ÆËãÈÕÆÚ¡£
GregorianCalendarºÍ ʱ¼ä
Á½¸öGregorianCalendarµÄ¹¹Ô캯Êý¿ÉÒÔÓÃÀ´´¦Àíʱ¼ä¡£Ç°Õß´´½¨Ò»¸ö±íʾÈÕÆÚ£¬Ð¡Ê±ºÍ·ÖÖӵĶÔÏó£º
GregorianCalendar(int year, int month, int date, int hour, int minute)
µÚ¶þ¸ö´´½¨Ò»¸ö±íʾһ¸öÈÕÆÚ£¬Ð¡Ê±£¬·ÖÖÓºÍÃ룺
GregorianCalendar(int year, int month, int date, int hour, int minute, int second)
Ê×ÏÈ£¬ÎÒÓ¦¸ÃÌáÐÑһϣ¬Ã¿Ò»¸ö¹¹Ô캯ÊýÐèҪʱ¼äÐÅÏ¢ÖеÄÈÕÆÚÐÅÏ¢(Ä꣬Ô£¬ÈÕ)¡£Èç¹ûÄãÏë˵2:30 p.m.,Äã±ØÐëÖ¸³öÈÕÆÚ¡£
ͬÑù£¬Ã¿Ò»¸öGregorianCalendar¹¹Ô캯Êý´´½¨Ò»¸öÔÚʱ¼äÉÏʹÓúÁÃë¼ÆËãµÄ¶ÔÏó¡£ËùÒÔ£¬Èç¹ûÄãµÄ¹¹Ô캯ÊýÖ»ÌṩÄ꣬Ô£¬ÈÕ²ÎÊý£¬ÄÇСʱ£¬·ÖÖÓ£¬ÃëºÍºÁÃëµÄÖµ½«±»ÖÃ0.
DateFormatºÍʱ¼ä
Äã¿ÉÒÔʹÓþ²Ì¬·½·¨getDateTimeInstance(int dateStyle,int timeStyle)À´½¨Á¢DateFormat¶ÔÏóÀ´ÏÔʾʱ¼äºÍÈÕÆÚ¡£Õâ¸ö·½·¨±íÃ÷ÄãÏëÒªµÄÈÕÆÚºÍʱ¼ä¸ñʽ¡£Èç¹ûÄãϲ»¶Ê¹ÓÃȱʡ¸ñʽ£¬¿ÉÒÔÊ
Ïà¹ØÎĵµ£º
KeywordFilter.java:
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class KeywordFilter
{
private static Pattern pattern = null;
private static KeywordFilter filter = new KeywordF ......
·þÎñÆ÷¶Ë:
package com.huahua;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
public class ServerThread extends Thread {
......
1 import
2 package
3 ÐÞÊηû
4 ³éÏóÀà ½Ó¿Ú
5 static
6 StringÏà¹Ø
7 javadoc
8 Òì³£
9 ÈÕÆÚÏà¹Ø
10 ÊäÈëÊä³öÁ÷
11
Ò» import
importÓÃÓÚµ¼È벻ͬ°üÖеÄÀ࣬²»Í¬°üÖеÄÀàÃû¿ÉÒÔÏàͬ¡£
ÓÃ*ºÅÖ»Äܵ¼ÈëÒ»¸ö°ü£¬²»ÄÜʹÓà import java.* »òÕß java.*. ......
JEditorPaneÌṩÈýÖÖÀàÐ͵ÄÎı¾ÏÔʾ£¬text/plain,text/html,text/rtf.
JEditorPaneµÄ¼òµ¥Ó÷¨DEMOÈçÏ£º
package ibees.swing;
import java.awt.Toolkit;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.event.Hype ......