Importjava.text.*;ImportJava.util.*; Public classDateFormat {/*** Format output of date type *@paramDate *@return */ Public StaticString DateFormat (date date) {SimpleDateFormat formatter=NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); String datestring=Formatter.format (date); returndatestring; } /*** Convert "2015-08-31-21:08:06" string to date *@paramSTR *@return * @throwsparseexception*/ Public StaticDate stringtodate (String str)throwsparseexception{SimpleDateFormat Formatte
Label:Just to implement a function, so write only one method, for easy invocation, set as static method 1 Packagecom.jv;2
3 Importjava.sql.Connection;4 ImportJava.sql.DriverManager;5
6 Public classLianjie {7
8 //static method Gets the Connection object
9 Public StaticConnection Getlianj ()throwsExceptionTen {
One
AClass.forName ("Oracle.jdbc.driver.OracleDriver"); -
-String url = "Jdbc:oracle:thin: @localhost: 1521:orcl";
the
-Connection conn = driv
} - - Threadpool.shutdown (); - } -}In the code, although there are 30 threads executing, only 10 concurrent executions are allowed. The semaphore method Semaphore (int permits) accepts an integer number that represents the number of licenses available. Semaphore (10) indicates that 10 threads are allowed to obtain a license, that is, the maximum number of concurrent is 10. The use of semaphore is also simple, with the first thread using Semaphore's acquire () to obtain a license,
public class MyDate {public static String GETDATECN () {SimpleDateFormat format = new SimpleDateFormat ("YYYY year mm month DD Day HH : Mm:ss "); String date = Format.format (new date (System.currenttimemillis ())), return date;//October 03, 2012 23:41:31}public Static String Getdateen () {SimpleDateFormat format1 = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); String date1 = Format1.format (New Date (System.currenttimemillis ())); return date1;//201
CodeImport java.util.collection;/** * */public class Emptyutil {/** * Determines whether a string is empty and a length of 0 is considered an empty string. * * @param str * @return */public static Boolean isEmpty (String str) {if (str! = null) { Return Str.trim (). Length () = = 0; } else {return true; }}/** * To determine if a string is empty, the string is truncated before and after it is truncated, and a length of 0 is
){ returnCellvalue; } //read the number as a string to avoid 1 Read 1.0 if(Cell.getcelltype () = =cell.cell_type_numeric) {Cell.setcelltype (cell.cell_type_string); } //determine the type of data Switch(Cell.getcelltype ()) { CaseCell.cell_type_numeric://DigitalCellvalue =string.valueof (Cell.getnumericcellvalue ()); Break; CaseCell.cell_type_string://stringCellvalue =string.valueof (Cell.getstringcellvalue ()); Break; CaseCell.cell_type_bo
The Tool class summarizes the rapid ordering of Java in simple and straightforward way. Hill sort, insert sort, heap sort, merge sort five sort algorithms, the code does not have a description of these sorts of algorithms, about the thought part wants to check the relevant instructions, here is only a summary of these algorithms for everyone to use.
publi
") Public voidsessiondestroyed (Httpsessionevent event) {HttpSession session=event.getsession (); ServletContext Application=Session.getservletcontext (); HashSet Sessions= (HashSet) application.getattribute ("Sessions"); //the destroyed session is removed from the hashset set.Sessions.remove (session); } /*** Access to the number of online users and number of users logged in *@paramrequest current Requested Object *@paramflag=1 Current Online users flag=2 number of currently logged on u
1. Get timestamp of N days ago1 Calendar cl = calendar.getinstance (); 2 Cl.add (Calendar.day_of_year,-7); 3 Date date = cl.gettime (); 4 long time = date.gettime (); 5 New Timestamp (time);2. Program start current time and task execution time1 /*2 Delegate Time3 */4String time= "20:00";5 6 /*7 SimpleDateFormat can parse string to Date, format Date to string8 */9DateFormat DateFormat =NewSimpleDateFormat ("Yy-mm-dd hh:mm");TenDateFormat DayFormat =NewSimpleDateFormat ("Yy-mm-dd"); One ADate cur
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.