public final class DateUtil extends Object
| Modifier and Type | Method and Description | 
|---|---|
static int | 
getDayFromCalendar(Calendar calendar)
Returns a date as the number of elapsed days from  
0001/01/01 (YYYY/MM/DD). | 
static int | 
getDayFromDate(Date date)
Returns a date as the number of elapsed days from  
0001/01/01 (YYYY/MM/DD). | 
static int | 
getDayFromDate(int year,
              int month,
              int day)
Returns a date as the number of elapsed days from  
0001/01/01 (YYYY/MM/DD). | 
static int | 
getDayFromSeconds(long seconds)
Converts the number of elapsed seconds from  
0001/01/01 (YYYY/MM/DD) 00:00:00 to
 the corresponded date as the number of elapsed days. | 
static int | 
getDayFromYear(int year)
Converts the year to the number of elapsed days from  
0001/01/01 (YYYY/MM/DD) about
 the first day of the specified year. | 
static int | 
getDayOfMonth(int dayOfYear,
             boolean leap)
Converts the number of elapsed days from beginning of the year to the date in the current month. 
 | 
static int | 
getMonthOfYear(int dayOfYear,
              boolean leap)
Converts the number of elapsed days from beginning of the year to the corresponding month. 
 | 
static long | 
getSecondFromCalendar(Calendar calendar)
Converts the date and time as the number of elapsed seconds from  
0001/01/01 (YYYY/MM/DD) 00:00:00. | 
static long | 
getSecondFromDate(Date date)
Converts the date and time as the number of elapsed seconds from  
0001/01/01 (YYYY/MM/DD) 00:00:00. | 
static int | 
getSecondFromTime(int hour,
                 int minute,
                 int second)
Converts the time as the number of elapsed seconds from  
00:00:00. | 
static int | 
getSecondOfDay(long seconds)
Converts the number of elapsed seconds from  
0001/01/01 (YYYY/MM/DD) 00:00:00 to
 the number of elapsed seconds from beginning of the corresponding date. | 
static int | 
getYearFromDay(int days)
Converts the number of elapsed days from  
0001/01/01 (YYYY/MM/DD) to the corresponding year. | 
static boolean | 
isLeap(int year)
Whether the target year is leap year or not. 
 | 
static int | 
parseDate(CharSequence value,
         char dateSegmentSeparator)
Parses a  
Date value. | 
static long | 
parseDateTime(CharSequence value,
             char dateSegmentSeparator,
             char dateTimeSeparator,
             char timeSegmentSeparator)
Parses a  
DateTime value. | 
static void | 
setDayToCalendar(int days,
                Calendar calendar)
Converts the number of elapsed days from  
0001/01/01 (YYYY/MM/DD) to the corresponded date,
 and set it to the target calendar object. | 
static void | 
setSecondToCalendar(long seconds,
                   Calendar calendar)
Converts the number of elapsed seconds from  
0001/01/01 (YYYY/MM/DD) 00:00:00 to the corresponded date,
 and set it to the target calendar object. | 
static void | 
toDateString(int elapsedDays,
            char dateSegmentSeparator,
            StringBuilder target)
Appends a string representation of  
Date. | 
static void | 
toDateTimeString(long elapsedSeconds,
                char dateSegmentSeparator,
                char dateTimeSeparator,
                char timeSegmentSeparator,
                StringBuilder target)
Appends a string representation of  
DateTime. | 
public static int getDayFromDate(int year,
                                 int month,
                                 int day)
0001/01/01 (YYYY/MM/DD).year - yearmonth - month (1-12)day - day (1-31)public static int getDayFromCalendar(Calendar calendar)
0001/01/01 (YYYY/MM/DD).calendar - the target calendar objectpublic static int getDayFromDate(Date date)
0001/01/01 (YYYY/MM/DD).date - the target date objectpublic static void setDayToCalendar(int days,
                                    Calendar calendar)
0001/01/01 (YYYY/MM/DD) to the corresponded date,
 and set it to the target calendar object.
 Note that, the hour, minute, second and millisecond fields will be set to 0.days - the number of elapsed days from 0001/01/01 (YYYY/MM/DD)calendar - the target calendar objectpublic static int getSecondFromTime(int hour,
                                    int minute,
                                    int second)
00:00:00.hour - hourminute - minutesecond - secondpublic static long getSecondFromCalendar(Calendar calendar)
0001/01/01 (YYYY/MM/DD) 00:00:00.calendar - the target calendar objectpublic static long getSecondFromDate(Date date)
0001/01/01 (YYYY/MM/DD) 00:00:00.date - the target date objectpublic static void setSecondToCalendar(long seconds,
                                       Calendar calendar)
0001/01/01 (YYYY/MM/DD) 00:00:00 to the corresponded date,
 and set it to the target calendar object.
 Note that, the millisecond fields will be set to 0.seconds - the number of elapsed secondscalendar - the target calendar objectpublic static int getYearFromDay(int days)
0001/01/01 (YYYY/MM/DD) to the corresponding year.days - the number of elapsed dayspublic static boolean isLeap(int year)
year - the target yeartrue if the target year is leap year, otherwise falsepublic static int getDayFromYear(int year)
0001/01/01 (YYYY/MM/DD) about
 the first day of the specified year.
 For example, getDayFromYear(1) returns just 0.year - the target yearpublic static int getMonthOfYear(int dayOfYear,
                                 boolean leap)
dayOfYear - the number of elapsed days from beginning of the yearleap - whether the target year is leap year or notpublic static int getDayOfMonth(int dayOfYear,
                                boolean leap)
dayOfYear - the number of elapsed days from beginning of the yearleap - whether the target year is leap year or notpublic static int getDayFromSeconds(long seconds)
0001/01/01 (YYYY/MM/DD) 00:00:00 to
 the corresponded date as the number of elapsed days.seconds - the number of elapsed seconds (0-origin)getSecondOfDay(long)public static int getSecondOfDay(long seconds)
0001/01/01 (YYYY/MM/DD) 00:00:00 to
 the number of elapsed seconds from beginning of the corresponding date.seconds - the number of elapsed seconds (0-origin)getDayFromSeconds(long)public static int parseDate(CharSequence value, char dateSegmentSeparator)
Date value.value - the date valuedateSegmentSeparator - the separator char between each date segmentDate objectpublic static long parseDateTime(CharSequence value, char dateSegmentSeparator, char dateTimeSeparator, char timeSegmentSeparator)
DateTime value.value - the date-time valuedateSegmentSeparator - the separator char between each date segmentdateTimeSeparator - the separator char between date and timetimeSegmentSeparator - the separator char between each time segmentDateTime objectpublic static void toDateString(int elapsedDays,
                                char dateSegmentSeparator,
                                StringBuilder target)
Date.elapsedDays - the number of elapsed days from 0001/01/01dateSegmentSeparator - the separator char between each date segmenttarget - the target bufferpublic static void toDateTimeString(long elapsedSeconds,
                                    char dateSegmentSeparator,
                                    char dateTimeSeparator,
                                    char timeSegmentSeparator,
                                    StringBuilder target)
DateTime.elapsedSeconds - the number of elapsed seconds from 0001/01/01 00:00:00dateSegmentSeparator - the separator char between each date segmentdateTimeSeparator - the separator char between date and timetimeSegmentSeparator - the separator char between each time segmenttarget - the target bufferCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.