Java Utililty Methods Year From

List of utility methods to do Year From

  1. HOME
  2. Java
  3. Y
  4. Year From

Description

The list of methods to do Year From are organized into topic(s).

Method

String getYear(boolean fourDigit)
Returns the current Year as a string (e.g.
if (mCalendar == null)
 Init();
String year = mCalendar.get(Calendar.YEAR) + "";
if (year.length() == 4 && fourDigit)
 return year;
return year.substring(2);
String getYear(int num)
get Year
Calendar calendar = new GregorianCalendar();
int year = calendar.get(Calendar.YEAR) + num;
int month = calendar.get(Calendar.MONTH);
String yearstr = "";
if (month < 8) {
 yearstr = String.valueOf(-1) + "/" + String.valueOf(year);
} else {
 yearstr = String.valueOf(year) + "/" + String.valueOf(year + 1);
...
int getYear(long t)
get Year
Calendar cld = Calendar.getInstance();
if (t > 0) {
 cld.setTime(new java.util.Date(t));
return cld.get(Calendar.YEAR);
Date getYearBegin(int year)
get Year Begin
Calendar ca = Calendar.getInstance();
truncate(ca);
ca.set(DAY_OF_MONTH, 1);
ca.set(MONTH, 0);
ca.set(YEAR, year);
return ca.getTime();
Date getYearFirst(int year)
get Year First
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(Calendar.YEAR, year);
Date currYearFirst = calendar.getTime();
return currYearFirst;
String getYearFormat(String dateString)
get Year Format
int start = 0;
int to = dateString.indexOf(".");
return dateString.substring(start, to);
int getYearFromDay(int days)
Converts the number of elapsed days from 0001年01月01日 (YYYY/MM/DD) to the corresponding year.
int cycles = days / DAYS_LEAP_CYCLE;
int cycleRest = days % DAYS_LEAP_CYCLE;
int centInCycle = cycleRest / DAYS_CENTURY;
int centRest = cycleRest % DAYS_CENTURY;
centRest += DAYS_CENTURY * (centInCycle / (YEARS_LEAP_CYCLE / YEARS_CENTURY));
centInCycle -= (centInCycle / (YEARS_LEAP_CYCLE / YEARS_CENTURY));
int leapInCent = centRest / DAYS_LEAP;
int leapRest = centRest % DAYS_LEAP;
...
Integer getYearFromISODate(String isoDate)
Method to return the year part from an iso date in either yyyy, yyyy-mm, or yyyy-mm-dd
Integer year = null;
if (isoDate.matches("\\d{4}")) { 
 year = new Integer(isoDate);
} else if (isoDate.matches("\\d{4}-\\d{2}") || isoDate.matches("\\d{4}-\\d{2}-\\d{2}")) {
 String[] sa = isoDate.split("-");
 year = new Integer(sa[0]);
} else if (isoDate.matches("\\d{8}")) { 
 String stringYear = isoDate.substring(0, 4);
...
int getYearFromTimestamp(long ms)
get Year From Timestamp
if (ms < 0)
 throw new NumberFormatException("argument must be positive");
Calendar cal = Calendar.getInstance(TIMEZONE, LOCALE);
cal.setTimeInMillis(ms);
return cal.get(Calendar.YEAR);
int getYearFromWeekCode(String weekCode)
get Year From Week Code
return Integer.parseInt(weekCode.substring(0, 4));


AltStyle によって変換されたページ (->オリジナル) /