In multi-language versions, the date and time format is a headache. Fortunately, Android provides DateFormate, which can be formatted Based on the default format of the specified language region.
Directly paste the Code:
Copy codeThe Code is as follows: public static CharSequence formatTimeInListForOverSeaUser (
Final Context context, final long time, final boolean simple,
Locale locale ){
Final GregorianCalendar now = new GregorianCalendar ();
// Special time
If (time
Return "";
}
// Today
First, Date, SimpleDateFormat, calendar difference and useIi.Overview of dates in Java Date in Java is a very complex piece of content, for a date in a different language country environment, date internationalization, conversion between date and time, dayPeriod of addition and subtraction operations, date presentation format is a very complex issue. In Java, the operation date mainly involves several classes: 1, Java.util.DateThe class Date represents a specific instantaneous, accurate to milli
Phase II:Basic management operations and getting started programs
Preface
Before explaining the basics of ColdFusion MX and Getting started, let's take a look at the differences between the various versions of ColdFusion MX. ColdFusion MX is currently divided into commercial and developer versions, while commercial versions include both Professional and Enter
system variable @ datefirst to obtain the current set datefirst value.The results of datename (DW, date) and datepart (DW, date) are affected by the set datefirst value.
Set dateformatSet dateformat is used to enter the order of the date (month, day, or year) of datetime or smalldatetime data. It is only used in the interpretation of converting a string to a date value. It does not affect the display of the date value.The specific syntax of set
Using Spring's MVC, you directly bind page parameters to an object, and an error occurs when a property in the object has a date, which needs to be handled at this time.
Similarly, other types that need to be processed can be used in this way.
Add code to Controller
@InitBinder
protected void Initbinder (HttpServletRequest request,
Servletrequestdatabinder binder) throws Exception {
//for properties that need to be converted to Date types, dateeditor is used fo
The methods of date classes in Java, Java date class methods
For more information, see http://blog.csdn.net/harryweasley/article/details/41977633,thank you.
This article mainly introduces four types: Date, DateFormat, SimpleDateFormat, and Calendar.
Date class:
Under the java. util package
The Date type indicates a specific moment, accurate to milliseconds.From JDK 1.1, use the Calendar class to convert the date and time fields, and use the
-- convert ---- date objectDate d = new Date (lo );DateFormatThe format time (the format style is fixed) is used in the java. text package.This DateFormat is an abstract class and cannot be used to create objects.Get the formatter:DateFormat. getDateInstance (); this type of format is only for the year-month-dayDateFormat. getDateTimeInstance (); // year-month-day hour: minute: SecondDateFormat. getDateInstance (int parameter): // specify the style b
Methods for date classes in Java
This article mainly introduces four types: Date, DateFormat, SimpleDateFormat, and Calendar.
Date class:
Under the java. util package
The Date type indicates a specific moment, accurate to milliseconds.From JDK 1.1, use the Calendar class to convert the date and time fields, and use the DateFormat class to format and analyze the date string. The corresponding method in Date
ClassThe locale instance object represents a specific geographic, political, and cultural area.A locale object itself does not verify that the language and country information it represents is correct, but that it provides national area information to locally sensitive classes, and that the formatting and parsing tasks associated with internationalization are done by locally sensitive classes. ( if a class in the JDK needs to adjust its functionality according to the Locale object at run time,
Java time processing (Continued Learning to calculate basic time periods in Java
Overview
If you know how to use date in Java, it is not as easy to use time as it is. This article tells you how to link their differences.
This article is based on 1. Java computing time depends on the number of milliseconds since January 1, January 1, 1970.
2. The date () constructor of the date class returns the object representing the current creation time. The date method gettime () returns a long value that is
'. $ test1 .'';
} Else {
Echo 'date error ';
}
2. determine whether the date format is correct
/**
* Determine whether the date format is correct
* Format: yyyy-mm-dd | yyyy-mm-dd hh: ii: ss
* @ Param $ tdate: determine the date
* @ Param $ dateformat the date format to be determined: "Y-m-d" or "Y-m-d H: I: s"
*/
Function is_date ($ tdate, $ dateformat
geographic, political, and cultural area.A locale object itself does not verify that the language and country information it represents is correct, but that it provides national area information to locally sensitive classes, and that the formatting and parsing tasks associated with internationalization are done by locally sensitive classes. ( if a class in the JDK needs to adjust its functionality according to the Locale object at run time, this class is called a local sensitive class )4.2.
); System.out.println (D.togmtstring ()); System.out.println (D.tolocalestring ()); System.out.println (D.gettime ());} }(2) DateFormatDateFormat class:This class is located under the Java.text package.This class is an abstract class, and this class cannot be directly new to the object.The DateFormat class is mainly to format date objects into string dataThe Date object, through the
= Calendar.getinstance ();Lastdate.set (calendar.date,1);//Set as number 1th of the current monthLastdate.add (calendar.month,-1);//Minus one months, change to 1th in next monthLastdate.add (calendar.date,-1);//Minus one day, becoming the last day of the monthStr=sdf.format (Lastdate.gettime ());return str;}Get the first day of the monthPublic String Getfirstdayofmonth () {String str = "";SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd");Calendar lastdate = Calendar.getinstance ();Lastda
geographic, political, and cultural area.A locale object itself does not verify that the language and country information it represents is correct, but that it provides national area information to locally sensitive classes, and that the formatting and parsing tasks associated with internationalization are done by locally sensitive classes. ( if a class in the JDK needs to adjust its functionality according to the Locale object at run time, this class is called a local sensitive class )4.2.
{
Echo ' date error ';
}
Copy Code2. Determine if the date format is correct
/**
* Determine if the date format is correct
* Judging Format Yyyy-mm-dd | YYYY-MM-DD Hh:ii:ss
* @param $tdate to determine the date
* @param $dateformat to determine the date format "y-m-d" or "y-m-d h:i:s"
*/
function Is_date ($tdate, $dateformat = "y-m-d") {
$tdate = Tr
"); java. util. date date2 = formatter2.parse ("2003-05 Friday"); SimpleDateFormat formatter3 = new SimpleDateFormat ("yyyy-MM-dd"); String mydate2 = formatter3.format (date2 ); // The day of the week. mydate = myFormatter. parse ("2001-1-1"); SimpleDateFormat formatter4 = new SimpleDateFormat ("E"); String mydate3 = formatter4.format (mydate );
In developing web applications, for different database date types, we need to convert the date types in our programs. If the corresponding database data
day of last month public string Getpreviousmonthfirst () {String str = "";
SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd");
Calendar lastdate = Calendar.getinstance (); Lastdate.set (calendar.date,1)//set to the current month of the number 1th Lastdate.add (calendar.month,-1),//minus one months, into the next month 1th number//lastdate.add (
CALENDAR.DATE,-1);/Minus one day, into the last day of the month Str=sdf.format (Lastdate.gettime ());
return str;
//Get the first day of the mont
View Articles
How to use date and calender classes in Java 2009-10-04 20:49Date and calendar are classes that provide time processing in the Java class Library, and because dates occupy an important place in the application of business logic, here you want to do a basic explanation of these two classes, because the technology is limited, please correct me.The date class, as the name implies, is known as a date-related class, the main function of this class is to get the cu
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.