Java,Date and Time 总结

    技术2022-05-11  36

    Agenda   What is UTC/UT?   What is GMT?   How to get the current time?   How to format it?   How to convert a string to a date/time?   How to process the date/time with database? Here's the answer:   java.lang.System  java.util.Date  java.util.Calendar  java.util.GregorianCalendar  java.util.TimeZone  java.text.DateFormat  java.text.SimpleDateFormat  java.sql.Date  java.sql.Time  java.sql.Timestamp Agenda   What is UTC/UT?   What is GMT?   How to get the current time?   How to format it?   How to convert a string to a date/time?   How to process the date/time with database? Here's the answer:   java.lang.System  java.util.Date  java.util.Calendar  java.util.GregorianCalendar  java.util.TimeZone  java.text.DateFormat  java.text.SimpleDateFormat  java.sql.Date  java.sql.Time  java.sql.Timestamp       http://img.blog.163.com/photo/xahA9HCw1p5aw4ECVbkj9w==/3430335541172882278.jpg   获得当前时间的方法:     System.currentTimeMillis();     Date d = new Date();    Calendar c = Calendar.getInstance();   字符串转换为时间:      String s = "1970-12-30 08:24:22.2";      Timestamp ts = Timestamp.valueOf(s);    获得其它时区时间:        Calendar cJapan = new GregorianCalendar(TimeZone.getTimeZone("Japan"));    

    最新回复(0)