Time Conversion and map collection

Source: Internet
Author: User

When the data in SQL is retrieved from MyEclipse in Java, it is returned by the result set object, then the data of the result object is received by the Map collection, and then the data is manipulated, because the data inside the map is of type object, So you can force the type to be converted to any type of data.

Result result=commondao.select (SQL, params);
for (int i = 0; i < Result.getrowcount (); i++) {
Map map=result.getrows () [i];
int Fwid=integer.parseint (Map.get ("Fwid"). toString ());
String T=map.get ("title"). ToString ();
Date date= (date) map.get ("date");
int Zj=integer.parseint (Map.get ("ZJ"). toString ());
int Uid=integer.parseint (Map.get ("UID"). toString ());
USERFWXX fwxx=new userfwxx (fwid,t,zj,uid,date);
List.add (FWXX);
}

------------------------------------------------------------------------------------------------------

This is what I forgot today that the data in the map is a objec type, but also worth it, should be to get through a knowledge point:

public static void Main (string[] args) throws exception{
String brithday = "1991-08-01";
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd");
Date d = sdf.parse (brithday); The parse () method is used to convert a string to a date type
System.out.println ("The time to convert to date type is:" +d);

}

When using the parse () method, note that the string format that is about to be transferred should be the same as the format defined in our SimpleDateFormat (), otherwise it cannot be converted;

Time Conversion and map collection

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.