These two tips, do not write do not know, a write scare!
Are seemingly simple, actually do up on the Meng, have to think carefully, can write right!
All have the date operation of the program should be careful Oh!
Let's say the second one:
2.
In mysql, we can use the DAYOFWEEK and WEEKDAY functions to obtain the week of the specified date. The difference is that the weekly index obtained by DAYOFWEEK starts with 1, and the weekly index obtained by WEEKDAY starts with 0.
DAYOFWEEK (date)
Weekday function
Returns an integer that represents the day of the week.
Weekday(date, [firstdayofweek])
Parameters
Date
An arbitrary expression that can represent a date. If NULL is included in the date argument, nullis
Weekday Function
Returns an integer representing the day of a week.
Weekday(date, [firstdayofweek])Parameters
Date
It can represent any expression of a date. IfDateIf the parameter contains Null, returnNull.
Firstdayofweek
Specify the constant of
When we want to implement a day of the week enumeration, We will write a class to implement it ourselves! The code for using the object class is as follows:
Package COM. jemsn. weekday; public class weekday {// privatize the constructor so that
Recently a little busy, directly paste code it, /// ///get the system for the week/// /// The English week /// Day of the week in Chinese Private Static stringGetweek (stringDT) { stringWeek ="";
Get the time of week Monday Zero (the start of the week) and Sunday 24 o'clock (that is, the end of this week and the start of the next week)NSDate *now =[NSDate Date]; Nscalendar*calendar =[Nscalendar Currentcalendar]; Nsdatecomponents*comp =
1/**2* 3* Findsunday Method-mainly used. Find Sunday4* 5* 6* Created by Xiayh creation time 2014-7-21-5:52:587* 8* 9* history change record Ten* One * Modified Person Modification Time description A* -* - * @return the */ -PrivateDate
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.