Date and time is most commonly used concepts in projects. In this post, we look in to the basic concepts of Calendar object and we will discussion about how to use in projects.
The Calendar
is an abstract class that provides methods for converting between a specific instant in time.
- calendar fields are YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on.
- It is used for manipulating date and time.
Syntax
Calendar calendar = Calendar.getInstance();
It allows for formatting (date -> text), parsing (text -> date), and normalization.It also supports localized date and time pattern strings
Date and Time Pattern Result
"yyyy.MM.dd G 'at' HH:mm:ss z" 2001.07.04 AD at 12:08:56 PDT
"EEE, MMM d, ''yy" Wed, Jul 4, '01
"h:mm a" 12:08 PM
"hh 'o''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" 0:08 PM, PDT
"yyyyy.MMMMM.dd GGG hh:mm aaa" 02001.July.04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z" Wed, 4 Jul 2001 12:08:56 -0700
"yyMMddHHmmssZ" 010704120856-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSZ" 2001-07-04T12:08:56.235-0700
Example
0 comments :
Post a Comment