当前位置:首页 » 服务器技术
开发技术指南» 文章正文
    引言: Java 语言的Calendar(日历),Date(日期),和DateFormat(日期格式)组成了Java标准的一个基本但是非常重要的部分。
 

 

 ·使用stopwatch类输出时间戳    »显示摘要«
    摘要:package com.generationjava.test;/*** useful when doing timings in a debug or test situation.*/public class stopwatch {static public int an_hour = 60 * 60 * 1000;static public int a_minute = 60 * 1000;......
 ·java类体中的this和super的用法    »显示摘要«
    摘要:一、基础知识 1、super(参数):调用基类中的某一个构造函数(应该为构造函数中的第一条语句) 2、this(参数):调用本类中另一种形成的构造函数(应该为构造函数中的第一条语句) 3、super: 它引用当前对象的直接父类中的成员(用来访问直接父类中被隐藏的父类中成员数据或函数,基类与派生类中有相同成员定义时) 如:super.变量名super.成员函数据名(实参) 4、this:它......


Java语言的Calendar和Date类
上一页   ...eeee是星期,mmmm是月,dd是日,yyyy是年.字符的个数决定了日期是如何格式化的.传递"ee-mm-dd-yy"会显示 sat-09-29-01.

【程序编程相关:从现在到2010年Wi-Fi城域网将增长

【推荐阅读:调查:2006蓝牙模块产品发货量将达50

将文本数据解析成日期对象 【扩展信息:思科圆梦数字家庭市场 一相情愿?

假设我们有一个文本字符串包含了一个格式化了的日期对象,我们希望解析这个字符串并从文本日期数据创建一个日期对象.我们将再次以格式化字符串"mm-dd-yyyy" 调用simpledateformat类.但是这一次,我们使用格式化解析而不是生成一个文本日期数据.我们的例子,显示在下面,将解析文本字符串"9-29-2001"并创建一个值为001736000000 的日期对象.

import java.text.simpledateformat;

import java.util.date;

public class dateexample3 {

public static void main(string[] args) {

// create a date formatter that can parse dates of

// the form mm-dd-yyyy.

simpledateformat bartdateformat = new simpledateformat("mm-dd-yyyy");

// create a string containing a text date to be parsed.

string datestringtoparse = "9-29-2001";

try {

// parse the text version of the date.

// we have to perform the parse method in a

// try-catch construct in case datestringtoparse

// does not contain a date in the format we are expecting.

date date = bartdateformat.parse(datestringtoparse);

// now send the parsed date as a long value

// to the system output.

system.out.println(date.gettime());

}

catch (exception ex) {

system.out.println(ex.getmessage());

}


...   下一页
 ·java语言的util类    »显示摘要«
    摘要:线性表,链表等是常用的数据结构,在进行java开发时,jdk已经为我们提供了一系列相应的类来实现基本的数据结构。这些类均在java.util包中。 collection ├list │├linkedlist │├arraylist │└vector │ └stack └set map ├hashtable ├hashmap └weakhashmap collection接口 collec......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE