Problem Description:
The actual programming process, often to output the date and time, but also the date and time to format the output.
Date and time can be converted to a string object, so date and time strings can be formatted using the format () function in the string class .
Programming Ideas:
1) It is clear that the format () function in the String class has two overloaded forms:
- public static string format (string format, Object ... args)
Function: Causes the string to be formatted according to the format specified by the parameter, and the new string after formatting uses the local default locale
@param format:String describes the expected formatting by this parameter
@param args:Object can have 0 or more of this type parameter
The type parameter is the variable referenced in the parameter format:String
@return a new string that is formatted as required
- public static string format (Locale l, string format, Object ... args)
Note: The only difference between this function and the above function is that the function can specify the locale used in the formatting process using the parameter Locale and the above functions can only be used by default in the locale
2) Specify formatin the above function:How theString parameter should be written
- Uses special symbols to represent the expected date and time format
The above converters are used for formatting dates and times, and the following conversions can be used for formatting of any parameter type:
3) Learn programming to format date and time strings after you have learned the basics above
4)
Java primary application----formatting---Date and time formatting