About the operation of the date operation

zhaozj2021-02-16  113

/ * ================================================================================================================================================================ ==== * function: to complete the conversion date string to ORACLE data format function * author: Chen Qingyu * completion date: May 13, 2004 * version: V1.0 * =========== ========================================================= * / package com.Unit.dateconversion; import Java.util.calendar; import com.Unit.validatenum. *;

public class DateConversion {ValidateNum VN = new ValidateNum (); // input string is three were: year, month, day public java.sql.Date DateConversion (String DateStr_Year, String DateStr_Month, String DateStr_Day) {int Date_Year; int Date_Month; int Date_Day; Date_Year = VN.StrToNum (DateStr_Year); Date_Month = VN.StrToNum (DateStr_Month); Date_Day = VN.StrToNum (DateStr_Day); Calendar cal = Calendar.getInstance (); cal.clear (); cal. Set (Date_Year, Date_Month, Date_day); java.util.date utildate = caver.gettime (); long nowtime = utildate.gettime (); java.sql.date nowDate = new java.sql.date (nowTime); Return Nowdate } // Enter a string, its value is the superimplete (such as: 20050515) public java.sql.date DateConversion (Int Date_Month; int Date_day; Date_Year = VN.STRTONUM {INT DATE_DAY (DATESTR.SUBSTRING (0, 4)); DATE_MONTH = VN.STRTONUM (4, 6)); DATE_DAY = VN.STRTONUM (DateStr.Substring (6,8)); Calendar Cal = Calendar.GetInstance ); Cal.clear (); Cal.Set (Date_Year, Date_Month-1, Date_day); J Ava.util.date utildate = caver.gettime (); long nowtime = utildate.gettime (); java.sql.date nowDate = new java.sql.date (nowtime); Return Nowdate;} // Enter a character Strings, its value is the superimposed day of the day (such as: 2005-05-15) public java.sql.date DateConversiona (String DateStr) {INT DATE_YEAR; INT DATE_MONTH; INT DATE_DAY; DATE_YEAR = VN.STRTONUM (DateStr.Substring) 0, 4)); DATE_MONTH = VN.STRTONUM (5,7)); DATE_DAY = VN.STRTONUM (DateStr.Substring (8, 10)); Calendar Cal = Calendar.GetInstance (); Cal.clear (); Cal.set (Date_Year, Date_Month-1, Date_Day); java.util.date utildate = CAL.GETTIME (); long nowtime = utildate.gettime ();

Java.sql.date nowDate = new java.sql.date (nowtime); returniful Date (server) public java.sql.date nowDate () {Calendar Cal = Calendar.GetInstance (); Java .util.date utildate = CAL.GETTIME (); long nowtime = utildate.gettime (); java.sql.date nowDate = new java.sql.date (nowtime); return noDate;} // get the first month One day public java.sql.date getfrontmixday () {Calendar cal = calendar.GetInstance (); int mixdaytodayMonth = 1; int nowyear = Cal.get (Cal.Year); int nowMonth = Cal.get (Cal.Mont) - 1; Cal.clear (); Cal.Set (Nowyear, NOWMONTH); java.util.date utildate = caver.getime (); long lowMaxTime = utildate.gettime (); java.sql.date nowmaxdate = new java .sql.Date (NowMaxTime); return NowMaxDate;} // get maximum date of the month [last day] public java.sql.Date getFrontMaxDay () {Calendar cal = Calendar.getInstance (); int MaxDayTodayMonth = cal.getActualMaximum (cal.day_of_month); int nowyear = Cal.get (Cal.Year); int nowMonth = Cal.get (Cal.Mont) -1; Cal.clear (); Cal.Set (nowyear, NOWMONTH, M axDayTodayMonth); java.util.Date UtilDate = cal.getTime (); long NowMaxTime = UtilDate.getTime (); java.sql.Date NowMaxDate = new java.sql.Date (NowMaxTime); return NowMaxDate;} // get the month maximum date (the server) public java.sql.Date MaxDateNowMonth () {Calendar cal = Calendar.getInstance (); int MaxDayTodayMonth = cal.getActualMaximum (cal.DAY_OF_MONTH); int NowYear = cal.get (cal.YEAR); int NowMonth = Cal.get (Cal.Mont); Cal.clear (); Cal.Set (Nowyear, NOWMONTH); Java.util.date Utildate = Cal.GetTime (); long nowMaxTime = utildate.gettime (); java .sql.date nowmaxdate = new java.sql.date (nowMaxtime);

转载请注明原文地址:https://www.9cbs.com/read-10386.html

New Post(0)