Calendar 类是一个抽象类,它为特定瞬间与一组诸如 YEAR、MONTH、DAY_OF_MONTH、HOUR 等 日历字段之间的转换提供了一些方法,并为操作日历字段(例如获得下星期的日期)提供了一些方法。瞬间可用毫秒值来表示,它是距历元(即格林威治标准时间 1970 年 1 月 1 日的 00:00:00.000,格里高利历)的偏移量。
例:
Calendar cal = Calendar.getInstance();//使用默认时区和语言环境获得一个日历。
cal.add(Calendar.DAY_OF_MONTH, -1);//取当前日期的前一天.
cal.add(Calendar.DAY_OF_MONTH, +1);//取当前日期的后一天.
//通过格式化输出日期
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");
System.out.println("Today is:"+format.format(Calendar.getInstance().getTime()));
System.out.println("yesterday is:"+format.format(cal.getTime()));
得到2007-12-25日期:
Calendar calendar = new GregorianCalendar(2007, 11, 25,0,0,0);
Date date = calendar.getTime();
System.out.println("2007 Christmas is:"+format.format(date));
//java月份是从0-11,月份设置时要减1.
//GregorianCalendar构造方法参 ......
出处:来源于CSDN ZangXT大虾对某篇关于java中栈与堆的文章的回复
大体分析一下
1. 栈(stack)与堆(heap)都是Java用来在Ram中存放数据的地方。与C++不同,Java自动管理栈和堆,程序员不能直接地设置栈或堆。
//栈都是由运行环境来处理的,这点C++和java没有什么不同.对于堆,不过java多了个GC.
2.这里的堆和栈首先要明确是虚拟机栈,和寄存器根本不是一个级别的东西,就别比较了.
3.栈数据共享好像是作者自己创造的概念.而且给基本类型也引入了"引用"的概念,不知道出于何种打算.
java虚拟机规范中说:Primitive values do not share state with other primitive values. A variable whose type is a primitive type always holds a primitive value of that type.
看一下实际的处理情况:
int a=3;
int b=3;
int c=65535;
int d=65535;
int e=32330;
int f=32330;
看对应的虚拟机指令,可以知道变量里实际存储的是什么:
Code ......
import java.util.LinkedList;
//单向队列
public class Queue {
public Queue() {
}
private LinkedList list = new LinkedList();
public void put(Object v) {
list.addFirst(v);
}
public Object get() {
return list.removeLast();
}
public boolean isEmpty() {
return list.isEmpty();
}
}
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
// 双向队列
public class DQueue implements Collection {
......
JSP:javascript 和 struts部分
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td>
<span class="txt1">三级单位:</span>
<html:select property="oilarea" style="width:182" styleId="area" onchange="javascript:fillWell()">
<c:forEach var="lessonmameshow" items="${requestScope.team1}">
<html:option value="${lessonmameshow.id}" ><c:out value="${lessonmameshow.name}"/></html:option>
</c:forEach>
</html:select>
<span class="txt1">队伍:</span>
<html:select property="oilwell" style="width:182" styleId="well">
<%
String id = (String)request.getAttribute("org");
if(request.getAttribute("org")!= null &&!"".equals(request.getAttribute("org"))){
List l = (List)request.getAttribute("ow");
for(int i=0;i<l.size();i++){
Orgteam o ......
/*从服务器中下载文件到本地*/
/*url:文件存放在服务器的地址;target:要保存的路径*/
public String DownloadFile(String url,String target){
URLConnection con=null;
URL theUrl=null;
try {
theUrl=new URL(url);//建立地址
con = theUrl.openConnection();//打开连接
con.setConnectTimeout(30000);
con.connect();//连接
} catch (MalformedURLException e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
return "给定的URL地址有误,请查看";
}
catch (IOException e) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
return "无法连接到远程机器,请重试!";
}
jLabel5.setText("√");
Process++;
File file = new File(gbl_ParentPath+"/UpdateTemp");
if(file.exists()==false){
......
//java.io
---------------------------------------------------------------
/**
* Title: 文件的各种操作
* Copyright: Copyright (c) 2004
* Company: 广东 有限公司
* @author 网络信息部 庆丰
* @version 1.0
*/
package common;
import java.io.*;
public class FileOperate {
public FileOperate() {
}
/**
* 新建目录
* @param folderPath String 如 c:/fqf
* @return boolean
*/
public void newFolder(String folderPath) {
try {
String filePath = folderPath;
filePath = filePath.toString();
java.io.File myFilePath = new java.io.File(filePath);
if (!myFilePath.exists()) {
myFilePath.mkdir();
}
}
......