new Date()当前日期格式

//取系统日期
    public String getDateWithString() {
        Calendar now = Calendar.getInstance();
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int year = now.get(Calendar.YEAR);
        String result = year + " 年 " + month + " 月 " + day + " 日 ";
        return result;
    }

//取系统日期
    public String getDateWithYMD() {
        Calendar now = Calendar.getInstance();
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int year = now.get(Calendar.YEAR);
        String date = year + "-" + month + "-" + day;
        return date;
    }

//取系统日期
    public String getDateWithNum() {
        Calendar now = Calendar.getInstance();
        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        String smonth = "" + month;
        String sday = "" + day;
        if (month < 10) {
            smonth = "0" + month;
        }
        if (day < 10) {
            sday = "0" + day;
        }
        String date = year + smonth + sday;
        return date;
    }

//取系统日期
    public Date getDate() {
        Calendar now = Calendar.getInstance();
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int year = now.get(Calendar.YEAR);
        String date = year + "-" + month + "-" + day;
        Date result = Date.valueOf(date);
        return result;
    }

时间: 2024-08-25 08:29:55

new Date()当前日期格式的相关文章

js转换Date日期格式

有时候做项目会用到js的date日期格式,因为Date()返回的格式不是我们需要的, Date()返回格式: Thu Mar 19 2015 12:00:00 GMT+0800 (中国标准时间) 而我们则需要这样的格式: 2015-3-19 12:00:00 除非是在后台处理好时间格式,然后在页面直接显示. 那如何用js格式化date日期值呢? 1.js方法返回值:2015-03-19 var formatDate = function (date) { var y = date.getFull

Date()日期格式转换

/** * 将长时间格式字符串转换为字符串 yyyy-MM-dd HH:mm:ss *  @return */ public static String longToStrng() { String time = "1256006105375";// long型转换成的字符串 Date date = new Date(Long.parseLong(time.trim())); SimpleDateFormat formatter = new SimpleDateFormat("

Eclipse 修改注释的 date time 日期时间格式,即${date}变量格式

Eclipse 修改注释的 date time 日期时间格式,即${date}变量格式 找到eclipse安装目录下面的plugins目录,搜索 org.eclipse.text ,找到一个jar包, 例如我找到的jar包为:org.eclipse.text_3.5.300.v20130515-1451.jar 然后打开它,找到这个类: org.eclipse.jface.text.templates.GlobalTemplateVariables 我们重写这个类就行了.(可反编译,也可以找到源

oracle中往varchar2格式的字段中插入date时间格式的值会发生什么?

--建立表test1 create table TEST1 ( ID    VARCHAR2(40) default sys_guid(), TDATE VARCHAR2(200) ) tablespace APP_TX_DATA pctfree 10 pctused 40 initrans 1 maxtrans 255 storage ( initial 64K minextents 1 maxextents unlimited ); --插入date时间格式数据 insert into te

SpringMVC返回Json,自定义Json中Date类型格式

http://www.cnblogs.com/jsczljh/p/3654636.html ———————————————————————————————————————————————————————————— SpringMVC返回Json,自定义Json中Date类型格式 SpringMVC返回Json数据依赖jackson这个开源的第三方类库. 若不加任何说明情况下Date类型将以时间戳的形式转换为Json并返回. jackson提供了一些自定义格式的方法.我们只需继承它的抽象类Json

Extjs4 中date时间格式的问题

在Grid中显示时间,后台传过来的是date格式的数据(PHP date('Y-m-d', time()),一般在Ext model中定义数据的类型和格式: {name:'birth', type:'date'}, view层: { header: '生日', dataIndex: 'birth', editor:{ xtype: 'datefield', format : 'Y-m-d'}} 但这是个可编辑的grid row,通过搜索得知,必须自己定义renderer,试过: renderer

WPF DatePicker默认显示当前日期,格式化为年月日(转)

WPF DatePicker默认显示当前日期,格式化为年月日 2018年08月08日 11:23:00 weixin_33922670 阅读数:253 原文:WPF DatePicker默认显示当前日期 WPF的日历选择控件默认为当前日期,共有两种方法,一种静态,一种动态. 静态的当然写在DatePicker控件的属性里了,动态的写在对应的cs文件里,具体请看下面. 1.方法一: myDatePicker.Text = DateTime.Today.ToLongDateString(); 2.方

DATE 日期格式

Oracle TO_DATE 日期格式 Oracle中TO_DATE格式2009-04-14 10:53TO_DATE格式(以时间:2007-11-02   13:45:25为例)            Year:              yy two digits 两位年                显示值:07         yyy three digits 三位年                显示值:007         yyyy four digits 四位年         

new Date() 日期格式处理

var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-????) myDate.getMonth(); //获取当前月份(0-11,0代表1月) // 所以获取当前月份是myDate.getMonth()+1; myDate.getDate(); //获取当前日(1-31) myDate.getDay(); //获取当前星期X(0-6,0代表星期天) myDa