Date和Srting转化

package com.jxhaina.warehouse.util;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class GetDate {

public GetDate(){

}

public static Date getNowDate()
{
Date currentTime = new Date();
return currentTime;
}

public static void main(String arg[]){

System.out.println(strToBirthday("2003-12-01"));

}

public static String getStringDate()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
return dateString;
}

public static String getStringDateShort()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
return dateString;
}

public static String getDateString(){

SimpleDateFormat simpledateformat = new SimpleDateFormat("yyMdHms");
String strTime = simpledateformat.format(new Date());
return strTime;

}
public static String dateToStrl(Date dateDate){
SimpleDateFormat simpledateformat = new SimpleDateFormat("yyMdHms");
String strTime = simpledateformat.format(dateDate);
return strTime;
}

public static Date strToDate(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}

public static String dateToStr(Date dateDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}

public static String dateToStrSh(Date dateDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(dateDate);
return dateString;
}

public static Date strToBirthday(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}

public static Date getNow()
{
Date currentTime = new Date();
return currentTime;
}

public static long getS(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate.getTime();
}

public static Date getLastDate(long day)
{
Date date = new Date();
long date_3_hm = date.getTime() - 0x74bad00L * day;
Date date_3_hm_date = new Date(date_3_hm);
return date_3_hm_date;
}

public static int getNowDay(String StrDate)
{
Date Time1 = strToDate(StrDate);
Date Time2 = new Date();
long day = Time1.getTime() - Time2.getTime();
return (int)day / 0x5265c00;
}

public static int getNowDay(Date StrDate)
{
Date Time1 = StrDate;
Date Time2 = new Date();
long day = Time1.getTime() - Time2.getTime();
return (int)day / 0x5265c00;
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值