6个回答
展开全部
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Test {
public static void main(String[] args) {
final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
SimpleDateFormat sdfInput = new SimpleDateFormat("yyyy年MM月dd日");
Calendar calendar = Calendar.getInstance();
Date date = new Date();
calendar.setTime(date);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
System.out.println(sdfInput.format(date) + " " + dayNames[dayOfWeek - 1]);
}
}
import java.util.Calendar;
import java.util.Date;
public class Test {
public static void main(String[] args) {
final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
SimpleDateFormat sdfInput = new SimpleDateFormat("yyyy年MM月dd日");
Calendar calendar = Calendar.getInstance();
Date date = new Date();
calendar.setTime(date);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
System.out.println(sdfInput.format(date) + " " + dayNames[dayOfWeek - 1]);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DataTest {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
Date date=calendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 E");
System.out.println(sdf.format(date));
}
}
------------------------------------------------------------------
2009年08月24日 星期一
import java.util.Calendar;
import java.util.Date;
public class DataTest {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
Date date=calendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 E");
System.out.println(sdf.format(date));
}
}
------------------------------------------------------------------
2009年08月24日 星期一
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Date d=new Date();
SimpleDateFormat sf=new SimpleDateFormat("yyyy年MM月dd日 E");
System.out.println(sf.format(d));
SimpleDateFormat sf=new SimpleDateFormat("yyyy年MM月dd日 E");
System.out.println(sf.format(d));
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
自已处理,很简单
public class TimeStamp {
public String getTimeStamp() {
return getDate()+getTime();
}
//private Date param=null;
private Calendar ca=Calendar.getInstance();
private String getYear()
{
int y = ca.get(Calendar.YEAR);
String year = ""+y;
return year;
}
private String getMonth()
{
int m = 1+ca.get(Calendar.MONTH);
String month ="";
if(m<10)month="0"+m;
else month=""+m;
return month;
}
private String getDay()
{
int d = ca.get(Calendar.DAY_OF_MONTH);
String day ="";
if(d<10)day="0"+d;
else day=""+d;
return day;
}
private String getHour()
{
int h = ca.get(Calendar.HOUR_OF_DAY);
String hour = "";
if(h<10)hour="0"+h;
else hour =""+h;
return hour;
}
private String getMinute()
{
int n = ca.get(Calendar.MINUTE);
String minute = "";
if(n<10)minute="0"+n;
else minute=""+n;
return minute;
}
private String getSecond()
{
int s = ca.get(Calendar.SECOND);
String second = "";
if(s<10)second="0"+s;
else second=""+s;
return second;
}
public String getDate()
{
return getYear()+getMonth()+getDay();
}
public String getDate2()
{
return getYear()+"/"+getMonth()+"/"+getDay();
}
public String getDate3()
{
return getMonth()+"/"+getDay()+"/"+getYear();
}
public String getTime()
{
return getHour()+ getMinute()+ getSecond();
}
public String getTimes()
{
return getYear()+"-"+getMonth()+"-"+getDay()+" "+getHour()+":"+ getMinute()+":"+ getSecond();
}
}
public class TimeStamp {
public String getTimeStamp() {
return getDate()+getTime();
}
//private Date param=null;
private Calendar ca=Calendar.getInstance();
private String getYear()
{
int y = ca.get(Calendar.YEAR);
String year = ""+y;
return year;
}
private String getMonth()
{
int m = 1+ca.get(Calendar.MONTH);
String month ="";
if(m<10)month="0"+m;
else month=""+m;
return month;
}
private String getDay()
{
int d = ca.get(Calendar.DAY_OF_MONTH);
String day ="";
if(d<10)day="0"+d;
else day=""+d;
return day;
}
private String getHour()
{
int h = ca.get(Calendar.HOUR_OF_DAY);
String hour = "";
if(h<10)hour="0"+h;
else hour =""+h;
return hour;
}
private String getMinute()
{
int n = ca.get(Calendar.MINUTE);
String minute = "";
if(n<10)minute="0"+n;
else minute=""+n;
return minute;
}
private String getSecond()
{
int s = ca.get(Calendar.SECOND);
String second = "";
if(s<10)second="0"+s;
else second=""+s;
return second;
}
public String getDate()
{
return getYear()+getMonth()+getDay();
}
public String getDate2()
{
return getYear()+"/"+getMonth()+"/"+getDay();
}
public String getDate3()
{
return getMonth()+"/"+getDay()+"/"+getYear();
}
public String getTime()
{
return getHour()+ getMinute()+ getSecond();
}
public String getTimes()
{
return getYear()+"-"+getMonth()+"-"+getDay()+" "+getHour()+":"+ getMinute()+":"+ getSecond();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询