Get a date by which the number of days before or after the date of

2010-03-24  来源:本站原创  分类:Java  人气:290 

Quote

In development can not help but use the date of operation, a few days ago, if the specified number of days before or after the date of the date formatting, etc.. Here is what I wrote a class on the date, the date commonly used operation.

import java.util.Calendar;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;

/**
 *   On the date of operation, such as formatting  ,  Forward and backward projections Date
 *
 * @  Of Liu Mingjing  ,  Hualong
 *
 * @  Time in 2008  11  17
 *
 */
public class DateUtil {

        static final SimpleDateFormat sdf0 = new SimpleDateFormat("yyyy  Month in MM  dd  Japan  ");
        static final SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        static final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        /**
         *   Determine the specified date. Date Time  .  Time is higher than the current date time  .
         *
         * @param theTime   Specified date. Date Time  .  Time  .
         * @return   Even after the return true, otherwise return  false.
         */
        public static boolean isAfter(String theTime) {
                switch (theTime.length()) {
                case 5:
                        return (get("HH:mm").compareTo(theTime) > 0);
                case 8:
                        return (get("HH:mm:ss").compareTo(theTime) > 0);
                case 11:
                        if (theTime.charAt(2) == ' ')
                                return (get("dd HH:mm:ss").compareTo(theTime) > 0);
                        if (theTime.charAt(5) == ' ')
                                return (get("MM-dd HH:mm").compareTo(theTime) > 0);
                case 14:
                        return (get("MM-dd HH:mm:ss").compareTo(theTime) > 0);
                case 17:
                        return (get("yy-MM-dd HH:mm:ss").compareTo(theTime) > 0);
                case 19:
                        return (get("yyyy-MM-dd HH:mm:ss").compareTo(theTime) > 0);
                }
                return false;
        }

        /**
         *   Determine the specified date. Date Time  .  Time than that before the current date and time  .
         *
         * @param theTime   Specified date. Date Time  .  Time  .
         * @return   Even before the return true, otherwise return  false.
         */
        public static boolean isBefore(String theTime) {
                switch (theTime.length()) {
                case 5:
                        return (get("HH:mm").compareTo(theTime) < 0);
                case 8:
                        return (get("HH:mm:ss").compareTo(theTime) < 0);
                case 11:
                        if (theTime.charAt(2) == ' ')
                                return (get("dd HH:mm:ss").compareTo(theTime) < 0);
                        if (theTime.charAt(5) == ' ')
                                return (get("MM-dd HH:mm").compareTo(theTime) < 0);
                case 14:
                        return (get("MM-dd HH:mm:ss").compareTo(theTime) < 0);
                case 17:
                        return (get("yy-MM-dd HH:mm:ss").compareTo(theTime) < 0);
                case 19:
                        return (get("yyyy-MM-dd HH:mm:ss").compareTo(theTime) >= 0);
                }
                return false;
        }

        /**
         *    Was scheduled in accordance with the format of the database to obtain the current date string  .
         *
         * * @return "yyyy-MM-dd"  The current time format string  .
         */
        public static String getDate() {
                return sdf2.format(new java.util.Date());
        }

        /**
         *   At that time, after the specified number of milliseconds for a date object  .
         *
         * @param seconds   Specified number of milliseconds  .
         * @return   After the specified number of milliseconds at the date of the object  .
         */
        public static java.util.Date getDate(long seconds) {
                return new java.util.Date(new java.util.Date().getTime() + seconds* 1000);
        }

        /**
         *    Was scheduled in accordance with the format of the database to obtain the current date string  .
         *
         * * @return "yyyy-MM-dd"  The current time format string  .
         */
        public static String getDate(Calendar ca) {
                return sdf2.format(ca.getTime());
        }

        /**
         *    Was scheduled in accordance with the format of the database to obtain the current date string  .
         *
         * * @return "yyyy-MM-dd"  The current time format string  .
         */
        public static String getDate(java.util.Date date) {
                return sdf2.format(date);
        }

        /**
         *   According to a specified date / time format to return date  /  Time string  .
         *
         * @param dateFormatString    Format string  .
         * @return   Formatted date string  .
         */
        public static String get(String dateFormatString) {
                try {
                        return new java.text.SimpleDateFormat(dateFormatString)
                                        .format(new java.util.Date());
                } catch (Exception e) {
                }
                return null;
        }

        /**
         *   In accordance with the given date  /  Time format     Generated by  java.util.Date  Object gives the date / time     String  .
         *
         * @param date   The specified Date object  .
         * @param dateFormatString   Format string  .
         * @return   Formatted date string  .
         */
        public static String get(java.util.Date date, String dateFormatString) {
                try {
                        return new java.text.SimpleDateFormat(dateFormatString)
                                        .format(date);
                } catch (Exception e) {
                }
                return null;
        }

        /**
         *   In accordance with the given date  /  Time format     Generated by  java.util.Calendar  Object gives the date / time     String  .
         *
         * @param calendar   Specified calendar object  .
         * @param dateFormatString   Format string  .
         * @return   Formatted date string  .
         */
        public static String get(java.util.Calendar calendar, String dateFormatString) {
                try {
                        return new java.text.SimpleDateFormat(dateFormatString).format(calendar
                                        .getTime());
                } catch (Exception e) {
                }
                return null;
        }

        /**
         *   Automatic analysis of multiple formats of date. Date Time  .  Time to resolve the Calendar object the string object  ,  Minimum level is second-class  .
         *   Currently supported formats  :
         * yyyy-MM-dd HH:mm:ss
         * MM-dd HH:mm:ss   The default is the year
         * dd HH:mm:ss   The default for the current month
         * dd HH:mm   The default is zero seconds, month, year
         * MM-dd HH:mm   The default is zero seconds, then
         * yyyy-MM-dd   The default is zero zero zero seconds
         * MM-dd   The default is the year 0:00:00
         * HH:mm:ss   The default is the year month day
         * HH:mm   The default is zero seconds, the day month year
         *
         * yyyy/MM/dd HH:mm:ss
         * yy/MM/dd HH:mm:ss
         * MM/dd HH:mm:ss
         * dd HH:mm:ss
         *
         * yyyy  Month in MM  dd  HH points on  mm  Minutes ss seconds
         * yy  Month in MM  dd  HH points on  mm  Minutes ss seconds
         * MM  Dd month day  HH  Point mm min  ss  Second
         * dd  HH points on  mm  Minutes ss seconds
         * HH  Point mm min  ss  Second
         * HH  Point mm min
         * @param datetime   Date. Date Time  .  Time string  .
         * @return   Analysis of a successful return to the calendar object, failure to return  null.
         */
        public static Calendar parse(String datetime) {

                if(datetime!=null){
                        //  While not a standard format, then format
                        if (datetime.length()!=19) {
                                datetime=formatToEnglish(datetime);
                        }
                        try {
                                //  Create a calendar object
                                Calendar rightNow = Calendar.getInstance();

                                //  Set the calendar turn to the specified date and time
                                rightNow.setTime(sdf1.parse(datetime));

                                //  Back to set a good date
                                return rightNow;

                        } catch (Exception e) { }
                }

                return null;

        }

        /**
         *   Date object with the specified date and time string format be  .
         *
         * @param date java.util.Date  Object  .
         * @return   Date Time string format  .
         */
        public static String getDateTime(java.util.Date date) {
                return sdf1.format(date);
        }

        /**
         *   With a given date by the specified number of seconds delay in the date time string  .
         *
         * @param date java.util.Date  Object  .
         * @param seconds   Seconds  .
         * @return   After the date and time delay  .
         */
        public static String getDateTime(java.util.Date date, int seconds) {
                return sdf1.format(new java.util.Date(date.getTime() + seconds * 1000));
        }

        /**
         *   Access today with a specified number of days between the calendar  .
         *
         * @param last   The specified calendar  .
         * @return   Calendar day of the specified number of days between  .
         */
        public static int getDays(Calendar last) {
                Calendar right = Calendar.getInstance();

                long theTime = right.getTimeInMillis() - last.getTimeInMillis();

                return (int) (theTime / (3600000 * 24));
        }

        private static int seed = 0;

        /**
         *   Access to the specified milliseconds string length  .
         * @param length   The specified string length  .
         * @return   Millisecond of a specified length of string  .
         */
        public static String getRandomString(int length) {
                seed++;

                Calendar right = Calendar.getInstance();
                String tmp = Long.toString(right.getTimeInMillis() * seed + seed);

                length = tmp.length() - length;

                return (length < 0) ? tmp : tmp.substring(length);
        }

        /**
         *   With the specified date and time format to the received date and time object  .
         *
         * @param dateFormatString   Date Time Format String  .
         * @return   Return java.util.Date date and time the object type  .
         */
        public static java.util.Date getToday(String dateFormatString) {
                try {
                        return parse(
                                        new java.text.SimpleDateFormat(dateFormatString)
                                                        .format(Calendar.getInstance().getTime()))
                                        .getTime();
                } catch (Exception e) {
                }

                return null;
        }

        /**
         *   Been designated the day after the date format date and time object  .
         *
         * @param dateFormatString   Date Time Format String  .
         * @return   Return java.util.Date date and time the object type  .
         */
        public static java.util.Date getTomorrow(String dateFormatString) {
                try {
                        return parse(
                                        new java.text.SimpleDateFormat(dateFormatString)
                                                        .format(new java.util.Date(new java.util.Date()
                                                                        .getTime() + 24 * 3600 * 1000))).getTime();
                } catch (Exception e) {
                }

                return null;
        }

        /**
         *   Back to today, several days before or after the date string  .
         * @param days   Specified number of days  ,"days<0"  Said days before the days  :"days>0"  Days after that day  ,"days=0"  That day  .
         * @return   Return the format "yyyy-MM-dd" date  .
         */
        public static String getDate(int days) {
                Calendar now = Calendar.getInstance();
                now.add(Calendar.DAY_OF_MONTH, days);
                return sdf2.format(now.getTime());
        }

        /**
         *   Specify the date by several days before or after the date of the date string  .
         * @param date   The specified date string  .
         * @param days   Specified number of days  ,"days<0"  Said days before the days  :"days>0"  Days after that day  ,"days=0"  That day  .
         * @return   Date string  .
         */
        public static String getDate(String date,int days){
                java.util.Date dateTemp = sdf2.parse(date, new ParsePosition(0));

                Calendar calendar = Calendar.getInstance();
                calendar.setTime(dateTemp);

                //   To the date of addition and subtraction
                calendar.add(Calendar.DATE, days);

                java.util.Date nowTime = calendar.getTime();

                StringBuffer buffer = sdf2.format(nowTime, new StringBuffer(""),new FieldPosition(0));

                return new String(buffer);
        }

        /**
         *   Formatted to  :"  Years "." Month  "."  Day "." When  "."  Points "." Seconds  "."-"."-".":"."/"." "." "
         *   Date Time Date Time split the string. Uniform date and time format into English  ,  Case  :2009-11-09 13:32:56.
         */
        public static String formatToEnglish(String datetime){
                String date=sdf2.format(Calendar.getInstance().getTime());

                String yy=date.substring(0,2);
                String year=date.substring(0,4);
                String month=date.substring(5,7);
                String day=date.substring(8,10);

                String datetimeBak=datetime.replace("  Japan  ", " ");
                datetimeBak=datetimeBak.replace(" ", " ");
                datetimeBak=datetimeBak.replaceAll(" +", " ");

                //  The date and time cut into two parts
                String dt[]=datetimeBak.split(" ");

                String format=null;

                String temp[]=getArray(datetime);
                if(temp!=null&&dt!=null){

                        switch (temp.length){
                        case 1:
                                //  Only days
                                if(temp[0].length()==1){
                                        temp[0]="0"+temp[0];
                                }
                                format=year+"-"+month+"-"+temp[1]+" 00:00:00";
                                break;
                        case 2:
                                for (int i = 0; i < temp.length; i++) {
                                        if(temp[i].length()==1){
                                                temp[i]="0"+temp[i];
                                        }
                                }

                                //  Determine the date or time
                                if(dt.length==1){
                                        //  Determine the time  :  By the time. Pm  .  Second component
                                        if(dt[0].contains(":")||dt[0].contains(":")||dt[0].contains("  Point  ")){
                                                format=year+"-"+month+"-"+day+" "+temp[0]+":"+temp[1]+":00";
                                        }
                                        //  Determine a date  :  By the month. On the composition of
                                        else{
                                                format=year+"-"+temp[0]+"-"+temp[1]+" 00:00:00";
                                        }
                                }
                                //  Determine the date and time  :  By the day. When the composition of
                                else if(dt.length==2){
                                        format=year+"-"+month+"-"+temp[0]+" "+temp[1]+":00:00";
                                }

                                break;
                        case 3:
                                //  Determine the date or time
                                if(dt.length==1){
                                        //  Determine the time  :  By the time. Pm  .  Second component
                                        if(dt[0].contains(":")||dt[0].contains(":")||dt[0].contains("  Point  ")){
                                                for (int i = 0; i < temp.length; i++) {
                                                        if(temp[i].length()==1){
                                                                temp[i]="0"+temp[i];
                                                        }
                                                }
                                                format=year+"-"+month+"-"+day+" "+temp[0]+":"+temp[1]+":"+temp[2];
                                        }
                                        //  Determine a date  :  By the years. Month  .  Date formed
                                        else{
                                                for (int i = 0; i < temp.length; i++) {
                                                        if(temp[0].length()!=4){
                                                                temp[0]=yy+temp[0];
                                                        }
                                                        else if(temp[i].length()==1){
                                                                temp[i]="0"+temp[i];
                                                        }
                                                }
                                                format=temp[0]+"-"+temp[1]+"-"+temp[2]+" 00:00:00";
                                        }
                                }
                                //  Determine the date and time  :  By the day. When the composition of
                                else if(dt.length==2){
                                        for (int i = 0; i < temp.length; i++) {
                                                if(temp[i].length()==1){
                                                        temp[i]="0"+temp[i];
                                                }
                                        }

                                        String dateArray[]=getArray(dt[0]);
                                        String timeArray[]=getArray(dt[1]);
                                        //  Judge for the month. Date  .  When the composition of
                                        if(dateArray.length==2 && timeArray.length==1){
                                                format=year+"-"+temp[0]+"-"+temp[1]+" "+temp[2]+":00:00";
                                        }
                                        //  Judge for the day. When  .  Grouped
                                        else if(dateArray.length==1 && timeArray.length==2){
                                                format=year+"-"+month+"-"+temp[0]+" "+temp[1]+":"+temp[2]+":00";
                                        }
                                }
                                break;
                        case 4:
                                //  Determine the date and time
                                if(dt.length==2){

                                        String dateArray[]=getArray(dt[0]);
                                        String timeArray[]=getArray(dt[1]);

                                        //  Judged on. Month  .  Days. When the composition of
                                        if(dateArray.length==3 && timeArray.length==1){
                                                for (int i = 0; i < temp.length; i++) {
                                                        if(temp[0].length()!=4){
                                                                temp[0]=yy+temp[0];
                                                        }
                                                        else if(temp[i].length()==1){
                                                                temp[i]="0"+temp[i];
                                                        }
                                                }
                                                format=temp[0]+"-"+temp[1]+"-"+temp[2]+" "+temp[3]+":"+"00:00";
                                        }
                                        else{
                                                for (int i = 0; i < temp.length; i++) {
                                                        if(temp[i].length()==1){
                                                                temp[i]="0"+temp[i];
                                                        }
                                                }

                                                //  Judge for the day. When  .  Minutes. Seconds component
                                                if(dateArray.length==1 && timeArray.length==3){
                                                        format=year+"-"+month+"-"+temp[0]+" "+temp[1]+":"+temp[2]+":"+temp[3];
                                                }
                                                //  Judge for the month. Date  .  Time. Grouped
                                                else if(dateArray.length==2 && timeArray.length==2){
                                                        format=year+"-"+temp[0]+"-"+temp[1]+" "+temp[2]+":"+temp[3]+":00";
                                                }
                                        }
                                }

                                break;
                        case 5:
                                if(dt.length==2){
                                        String dateArray[]=getArray(dt[0]);
                                        String timeArray[]=getArray(dt[1]);
                                        //  Judge for the month. Date  .  Time. Pm  .  Second component
                                        if(dateArray.length==2 && timeArray.length==3){
                                                for (int i = 0; i < temp.length; i++) {
                                                        if(temp[i].length()==1){
                                                                temp[i]="0"+temp[i];
                                                        }
                                                }
                                                format=year+"-"+temp[0]+"-"+temp[1]+" "+temp[2]+":"+temp[3]+":"+temp[4];
                                        }
                                        //  Judged on. Month  .  Days. When  .  Grouped
                                        else if(dateArray.length==3 && timeArray.length==2){
                                                for (int i = 0; i < temp.length; i++) {
                                                        if(temp[0].length()!=4){
                                                                temp[0]=yy+temp[0];
                                                        }
                                                        else if(temp[i].length()==1){
                                                                temp[i]="0"+temp[i];
                                                        }
                                                }
                                                format=temp[0]+"-"+temp[1]+"-"+temp[2]+" "+temp[3]+":"+temp[4]+":00";
                                        }
                                }
                                break;
                        case 6:
                                for (int i = 0; i < temp.length; i++) {
                                        if(temp[0].length()!=4){
                                                temp[0]=yy+temp[0];
                                        }
                                        else if(temp[i].length()==1){
                                                temp[i]="0"+temp[i];
                                        }
                                }
                                format=temp[0]+"-"+temp[1]+"-"+temp[2]+" "+temp[3]+":"+temp[4]+":"+temp[5];
                                break;
                        }
                }

                return format;
        }

        /**
         *   Prone to a variety of English in the format of the date and time of the conversion into an array  .
         */
        private static String[] getArray(String datetime){
                String array[]=null;
                if(datetime!=null){

                        //  Replace the half-angle space
                        datetime=datetime.replace(" ", "-");

                        //  To replace the whole angle space
                        datetime=datetime.replace(" ", "-");
                        datetime=datetime.replace("  Years ", "-");
                        datetime=datetime.replace("  Month  ", "-");
                        datetime=datetime.replace("  Japan  ", "-");
                        datetime=datetime.replace("  Point  ", "-");
                        datetime=datetime.replace("  Point  ", "-");
                        datetime=datetime.replace("  Second  ", "");
                        datetime=datetime.replace(",", "-");
                        datetime=datetime.replace(",", "-");
                        datetime=datetime.replace(".", "-");
                        datetime=datetime.replace(":", "-");
                        datetime=datetime.replace(":", "-");
                        datetime=datetime.replace("-", "-");
                        datetime=datetime.replace("/", "-");
                        //  Multiple "-" replace a  "-"
                        datetime=datetime.replaceAll("-+", "-");

                        //  The date and time each item is divided into
                        array=datetime.split("-");
                }

                return array;
        }

        /**
         *   Formatted to  :"  Years "." Month  "."  Day "." When  "."  Points "." Seconds  "."-"."-".":"."/"." "." "
         *  Date Time Date Time split the string. Uniform date and time format into Chinese  ,  Case  :2009  In November  09  Day 13:00  32  Minutes 56 seconds  .
         */
        public static String formatToChinese(String datetime){
                datetime=formatToEnglish(datetime);
                if(datetime==null||datetime.equals("")){
                        return null;
                }

                String str[]=datetime.split(":|-| ");

                return str[0]+"  Years "+str[1]+"  Month  "+str[2]+"  Japan   "+str[3]+"  Point  "+str[4]+"  Point  "+str[5]+"  Second  ";
        }
相关文章
  • Get a date by which the number of days before or after the date of 2010-03-24

    Quote In development can not help but use the date of operation, a few days ago, if the specified number of days before or after the date of the date formatting, etc.. Here is what I wrote a class on the date, the date commonly used operation. import

  • A given date from today (current) number of working days! 2011-01-06

    Online search sql statement, I feel useful, write down the friends - Find a given date from today (current) number of working days! CREATE OR REPLACE FUNCTION workdays_today (i_date IN VARCHAR2) - enter the date parameters, use varchar2 type, the dat

  • javascript regular expression match date, E-mail, mobile phone number 2010-06-02

    Match the date format :/^([ 1-2] \ d (3)) [\ / | \ -] (0? [1-9] | 10 | 11 | 12) [\ / | \ -] ([1 -2]? [0-9] | 0 [1-9] | 30 | 31) $ / This regular expression can match the correct date format, but can not distinguish between the size of the month and l

  • Java: calculating a date with the specified number of days (excluding Saturdays, Sundays and a series of festivals) 2010-11-20

    Work experience, wrote a casual welcome to master Comments: Core code: package www.sjjjob.com.date; import java.util.ArrayList; import java.util.Calendar; import java.util.List; / ** * Date of public functions * @ Author shenjunjie * @ Version [s001,

  • SQL Server date functions with a number of days in a month the program received 2010-12-01

    This article describes the key to all SQL Server date function of the actual number of days a month to obtain the correct steps in the actual grass group, if you want to get the number of days a month of its main operating skills are: first to the la

  • Date of operation a number of cases of PHP 2010-03-22

    1. For a given date and time of two strings (such as 2010-03-21 04:26:21), calculate the time interval is more than a day $date1=strtotime('2010-03-21 04:26:21'); $date2=strtotime('2010-03-22 04:26:19'); $secondsInOneDay = 60 * 60 * 24; $period = $da

  • Java Date subtraction by the number of days.! 2010-04-25

    import java.util.Date; import java.text.SimpleDateFormat; import java.util.Calendar; public class DateCal ( / ** * @ Param args * / public static void main (String [] args) throws Exception ( / / TODO Auto generated method stub / / Date calculated by

  • SQL SERVER date functions on a number of conversion 2010-10-14

    Sql Server in a very powerful date formatting function Turn date string Select cast ('2009-01-01 'as datetime) Date format conversion Select CONVERT (varchar (100), GETDATE (), 0): 05 16 2006 10:57 AM Select CONVERT (varchar (100), GETDATE (), 1): 05

  • sql date calculation of the number of months in paragraph 2010-11-18

    select (end_year-start_year) * 12 + end_mon-start_mon +1 as months from ( select year ('2009-02-20 ') as start_year, year (current_date ()) as end_year, month ('2009-02-20 ') as start_mon, month (current_date ()) as end_mon ) Aa Dynamic Version selec

  • JS date type of order (transfer) 2010-04-23

    JavaScript_Date Object Description Date Chinese as "date" means, Date inherited from Object object, this object provides operations to show the date and time functions Reference URL: http://www.dreamdu.com/javascript/object_date/ Date object con

  • javascript Date object 2010-08-02

    Date object constructor new Date () new Date (milliseconds) new Date (datestring) new Date (year, month) new Date (year, month, day) new Date (year, month, day, hours) new Date (year, month, day, hours, minutes) new Date (year, month, day, hours, min

  • Order number of the design 2010-08-04

    1. If the order does not require the order number generated continuously, each time an order number at the same time initialization order number + +, many people also use the number of conflicts will not occur. function getNextNumber ($ field, $ job)

  • The legitimacy of the new and old ID card verification and validation algorithm 2010-03-28

    1. Chinese citizen ID card common sense: China's current use of citizen identity card numbers, there are two standards for the two countries can follow,] [GB 11643-1989 and GB 11643-1999] [. GB 11643-1989] [specified ID number is 15: in the order fro

  • [Reprinted] Oracle built-in SQL functions - sorting Daquan 2010-03-02

    Oracle built-in SQL functions - sorting Daquan F.1 Character Functions - return character value These functions are all family received a character type parameter (CHR excluded) and the return character value. In addition to the special note, the maj

  • Chapter VI of the JavaScript built-in objects 2010-05-03

    [/ Size] What is the definition of the function function function function call function of the parameter recursive function closure Array (key) Boolean (primitive data type of wrapper class) Date (key) Math (second priority) Number (primitive data t

  • JavaScript built-in functions and local functions 2010-06-08

    A total of javascript function can be divided into five categories: * Array of function Date function routine functions mathematical functions string functions 1. General function javascript routine functions include the following nine functions: (1)

  • Oracle Function Classification concluded. 2010-09-19

    Oracle built-in SQL functions - sorting Daquan F.1 Character functions - all of these functions to return character value received is the type of parameters ethnic character (CHR excluded) and the return character value. In addition to the special no

  • Common Functions SQL Collection 2011-08-26

    First, the character conversion functions 1, ASCII () Returns a character expression the leftmost characters of the ASCII code value. In the ASCII () function, the string can be a pure number''not enclosed, but with other characters in the string mus

  • mysql date function - date back to subtract the number of days 2010-06-06

    MySQL datediff (date1, date2): subtracting two dates date1 - date2, return the number of days. select datediff ('2008-08-08 ', '2008-08-01'); - 7 select datediff ('2008-08-01 ', '2008-08-08'); - -7 Reference: MySQL: date function, time function sum (

  • (Transfer) ORACLE using SQL realize the time and date by the number of milliseconds to convert the string 2010-06-29

    Original Source: http://hi.baidu.com/78347079/blog/item/14a05afd868d291f08244d15.html In the development process, in order to facilitate the regular time and date will be the number of milliseconds to keep shaping the format to the database, although