当前位置: 技术问答>java相关
如何取到格式2002-05-06的日期!(在线,急)
来源: 互联网 发布时间:2015-10-05
本文导语: 如何取到格式2002-05-06的日期!(在线,急) | 什么意思? 说清楚点。你是要取06吗?? | //取得当前时间[date] Calendar calendar=Calendar.getInstance(); int year=calendar.get(Calendar.Y...
如何取到格式2002-05-06的日期!(在线,急)
|
什么意思?
说清楚点。你是要取06吗??
说清楚点。你是要取06吗??
|
//取得当前时间[date]
Calendar calendar=Calendar.getInstance();
int year=calendar.get(Calendar.YEAR);
int month=calendar.get(Calendar.MONTH)+1;
int day=calendar.get(Calendar.DATE);
int hour=calendar.get(Calendar.HOUR_OF_DAY);
int minute=calendar.get(Calendar.MINUTE);
int second=calendar.get(Calendar.SECOND);
String date=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
out.println(date);
Calendar calendar=Calendar.getInstance();
int year=calendar.get(Calendar.YEAR);
int month=calendar.get(Calendar.MONTH)+1;
int day=calendar.get(Calendar.DATE);
int hour=calendar.get(Calendar.HOUR_OF_DAY);
int minute=calendar.get(Calendar.MINUTE);
int second=calendar.get(Calendar.SECOND);
String date=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
out.println(date);
|
java.util.Date d=new java.util.Date();
java.text.SimpleDateFormat dformat=new java.text.SimpleDateFormat("yyyy-MM-dd");
String dateandtime=dformat.format(d);
java.text.SimpleDateFormat dformat=new java.text.SimpleDateFormat("yyyy-MM-dd");
String dateandtime=dformat.format(d);
|
String date=year+"-"+String.valueOf(month+100).substring(1,3)+"-"+String.valueOf(day+100).substring(1,3);
out.println(date);
out.println(date);
|
DateFormat df=DateFormat.getDateInstance();
out.print(df.format((new Date()));
out.print(df.format((new Date()));
|
在ORACLE数据库中:
select to_char(sysdate,'YYYY-MM-DD') from dual;
用javascript:
用java:
import java.util.Calendar;
public class testTime
{
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
int YearInt,MonthInt,DateInt;
String MonthStr,DateStr;
YearInt=calendar.get(calendar.YEAR);
MonthInt=calendar.get(calendar.MONTH)+1;
if(MonthInt
select to_char(sysdate,'YYYY-MM-DD') from dual;
用javascript:
用java:
import java.util.Calendar;
public class testTime
{
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
int YearInt,MonthInt,DateInt;
String MonthStr,DateStr;
YearInt=calendar.get(calendar.YEAR);
MonthInt=calendar.get(calendar.MONTH)+1;
if(MonthInt