Obtains the current time of the local machine.

Source: Internet
Author: User
Tags date now dateformat

Local call time in the application. When displayed on the screen, you can write it into the configuration file for calling;

/*** Get the current time ** @ return */public static string getcurtime () {date now = new date (); simpledateformat dateformat = new simpledateformat ("mmddhhmm "); string time = dateformat. format (now); return time;} public static int getday () {calendar now = calendar. getinstance (); int day = now. get (calendar. day_of_month); return day;} public static int getmonth () {calendar AR now = calendar ar. getinstance (); int month = now. get (calendar. month); Return month;} public static string getweek () {calendar now = calendar. getinstance (); int week = now. get (calendar. day_of_week); string str_week = ""; Switch (week) {Case 1: str_week = "Sunday"; break; Case 2: str_week = "Monday"; break; Case 3: str_week = "Tuesday"; break; Case 4: str_week = "Wednesday"; break; Case 5: str_week = "Thursday"; break; Case 6: str_week = "Friday "; break; Case 7: str_week = "Saturday"; break; default: break;} return str_week ;}

 

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.