Convert util. date to uppercase (lunar calendar) Time

Source: Internet
Author: User

recently, the company's projects need to export word to the customer, and the customer needs to export the date format in uppercase. No way. I found a Article on the Internet to convert the date format.

Package base. datetime; </P> <p> Import Java. util. calendar; <br/> Import Java. util. date; </P> <p> /******************************** **************************************** * ************************* <br/> * <B> function: </B> date tool class: Set util. convert a date to a large write date format <br/> * @ project Web <br/> * @ Package base. datetime <br/> * @ filename dateutils. java <br/> * @ createdate 10:24:47 <br/> */<br/> public class dateutils {<br/> // convert the date to uppercase or lowercase <br/> Public static string datatoupper (date) {<br/> calendar CA = calendar. getinstance (); <br/> Ca. settime (date); <br/> int year = Ca. get (calendar. year); <br/> int month = Ca. get (calendar. month) + 1; <br/> int day = Ca. get (calendar. day_of_month); <br/> return numtoupper (year) + "year" + monthtouppder (month) + "month" + daytouppder (day) + "day "; <br/>}</P> <p>/*** <br/> * <B> function: </B> convert the number to uppercase <br/> * @ createdate 10:28:12 <br/> * @ Param num number <br/> * @ return the converted uppercase number. <br/> */<br/> Public static string numtoupper (INT num) {<br/> // string U [] = {"zero", "one", "two", "three", "Si", "Wu ", "Lu", "Lu" };< br/> // string U [] = {"0", "1 ", "2", "3", "4", "5", "6", "7", "8", "9 "}; <br/> string U [] = {"○", "1", "2", "3", "4", "5", "6 ", "7", "8", "9" };< br/> char [] STR = string. valueof (Num ). tochararray (); <br/> string rstr = ""; <br/> for (INT I = 0; I <Str. length; I ++) {<br/> rstr = rstr + U [integer. parseint (STR [I] + "")]; <br/>}< br/> return rstr; <br/>}</P> <p>/*** <br/> * <B> function: </B> converts a month to uppercase. <br/> * @ createdate 2010-5-27 10:41:42 am <br/> * @ Param month <br/> * @ return returns the uppercase month after conversion. <br/> */<br/> Public static string monthtouppder (INT month) {<br/> If (month <10) {<br/> return numtoupper (month); <br/>} else if (month = 10) {<br/> return "10"; <br/>} else {<br/> return "10" + numtoupper (month-10 ); <br/>}</P> <p>/***** <br/> * <B> function: </B> converts a date to uppercase <br/> * @ createdate 10:43:32 <br/> * @ Param day date <br/> * @ return converts the uppercase Date Format <br/> */<br/> Public static string daytouppder (INT Day) {<br/> If (day <20) {<br/> return monthtouppder (day); <br/>} else {<br/> char [] STR = string. valueof (day ). tochararray (); <br/> If (STR [1] = '0') {<br/> return numtoupper (integer. parseint (STR [0] + "") + "10"; <br/>}else {<br/> return numtoupper (integer. parseint (STR [0] + "") + "10" + numtoupper (integer. parseint (STR [1] + "")); <br/>}</P> <p> Public static void main (string [] ARGs) {</P> <p> system. out. println (dateutils. datatoupper (new date (); <br/>}< br/>}

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.