java.lang.Object
java.util.Calendar
- All Implemented Interfaces:
- Serializable, Cloneable, Comparable<Calendar>
- Direct Known Subclasses:
- GregorianCalendar
- See Also:
- Top Examples, Source Code,
GregorianCalendar.roll(int, int)
, calendar fields
, System.currentTimeMillis()
,
Date
,
TimeZone
,
DateFormat
public abstract void add(int field,
int amount)
- See Also:
set(int,int)
, roll(int,int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[222]Calendar addition
By Anonymous on 2005/09/27 05:59:10 Rate
Calendar calADD = java.util.GregorianCalendar.getInstance ( ) ;
System.out.println ( calADD.getTime ( ) ) ;
[481]_
By Thorkil Blumensaadt on 2005/09/27 05:58:52 Rate
Calendar c = Calendar.getInstance ( ) ;
c.add ( Calendar.MONTH, 1 ) ;
[683]_
By Anonymous on 2005/06/02 23:07:25 Rate
Calendar c = Calendar.getInstance ( ) ;
c.add ( Calendar.MONTH, 1 ) ;
[830]_
By Ajay on 2005/06/02 06:07:35 Rate
Calendar calADD = java.util.GregorianCalendar.getInstance ( ) ;
System.out.println ( calADD.getTime ( ) + " Time After 10 days will be :" +
calADD.add ( Calender.Date, 10 ) ) ;
[1789]Yesterday's DAY_OF_YEAR
By Anonymous on 2006/07/21 16:09:10 Rate
import java.util.*;
public class jDate {
public static void main ( String args [ ] )
{
// Get the Julian day of the year for the report dates
Calendar cal = Calendar.getInstance ( ) ; // Get instance of calendar object
int today = cal.get ( Calendar.DAY_OF_YEAR ) ; // Get today's number of day in the year
System.out.println ( "Today: " + today ) ;
cal.add ( Calendar.DAY_OF_YEAR, -1 ) ; // Move to yesterday
int yesterday = cal.get ( Calendar.DAY_OF_YEAR ) ; // Get yesterday's number of day in the year
System.out.println ( "Yesterday: " + yesterday ) ;
cal.add ( Calendar.DAY_OF_YEAR, -6 ) ; // Move to a week before today ( already moved to yesterday )
int lastWeek = cal.get ( Calendar.DAY_OF_YEAR ) ; // Get a week before today's number of day in the year
System.out.println ( "Last week: " + lastWeek ) ;
} // End main
} // End userEmails
public boolean after(Object when)
- See Also:
compareTo(Calendar)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[913]Compare Calendar
By Anonymous on 2005/06/30 17:33:16 Rate
The 'after' & 'before' methods take the 'Object' as its input parameter, but in fact it must be a Calendar object, it can not be anyother type, like java.util.Date.
[1536]_
By Nicole Best on 2005/09/13 23:05:04 Rate
Calendar timeNow = Calendar.getInstance ( ) ; // Time now
Calendar timeLater = Calendar.getInstance ( ) ; // Time in future
timeLater.add ( Calendar.SECOND, 5 ) ;
SimpleDateFormat dateFormat = new SimpleDateFormat ( "HH:mm:ss" ) ;
System.out.println ( "Check: is " + dateFormat.format ( timeNow.getTime ( ) ) + " after ( " + dateFormat.format ( timeLater.getTime ( ) ) + " ) " ) ;
// Example of method in use
boolean result = timeNow.after ( timeLater ) ;
System.out.println ( "Result: " + result ) ;
[1860]Iterating in a date range (from a start date to an end date inclusive)
By Kai Middleton on 2007/01/09 12:49:25 Rate
SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:SS" ) ;
Calendar startCal = Calendar.getInstance ( ) ;
Calendar endCal = Calendar.getInstance ( ) ;
startCal.setTime ( new Date ( 1170000000000L ) ) ; // 2007-01-28 08:00:00
endCal.setTime ( new Date ( 1170000000000L ) ) ; // 2007-02-01 08:00:00
endCal.add ( Calendar.DAY_OF_YEAR, 4 ) ;
System.out.println ( sdf.format ( startCal.getTime ( ) ) + " = startDate" ) ;
System.out.println ( sdf.format ( endCal.getTime ( ) ) + " = endDate" ) ;
System.out.println ( "----------------------------" ) ;
for ( Calendar c = startCal; c.compareTo ( endCal ) < = 0; c.add (
Calendar.DAY_OF_YEAR, 1 ) )
System.out.println ( sdf.format ( c.getTime ( ) ) ) ;
result:
2007-01-28 08:00:00 = startDate
2007-02-01 08:00:00 = endDate
----------------------------
2007-01-28 08:00:00
2007-01-29 08:00:00
2007-01-30 08:00:00
2007-01-31 08:00:00
2007-02-01 08:00:00
Note that the start and end dates have to match down to the millisecond in order for the comparison to work properly. Otherwise the end date might not be included.
public static final int AM
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int AM_PM
- See Also:
HOUR
, PM
, AM
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int APRIL
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean areFieldsSet
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int AUGUST
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean before(Object when)
- See Also:
compareTo(Calendar)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Calendar()
- See Also:
TimeZone.getDefault()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[689]Correct way to calculate endDate string
By Anonymous on 2004/12/23 12:11:00 Rate
String startDate = "02/01/04";
SimpleDateFormat sdf = new SimpleDateFormat ( "mm/dd/yyyy" ) ;
Date dStartDate = sdf.parse ( startDate ) ;
Calendar stCal = Calendar.getInstance ( ) ;
stCal.setTime ( dStartDate ) ;
Calendar endCal = Calendar.getInstance ( ) ;
endCal = stCal.add ( Calendar.MONTH,1 ) ;
endCal = endCal.add ( Calendar.DAY_OF_MONTH,-1 ) ;
String endDate = endCal.toString ( ) ;
[960]_
By Anonymous on 2005/02/28 12:12:36 Rate
endCal = stCal.add ( Calendar.MONTH,1 ) ;
cannot work since
stCal.add ( Calendar.MONTH,1 ) ; sends void back
so do endCal = stCal.add;
in a second step !
[1473]_
By Hemanth Kumar on 2005/07/06 19:57:52 Rate
//setting the month to February
calendar.set ( Calendar.MONTH,1 ) ;
calendar.set ( Calendar.DATE,1 ) ;
calendar.add ( Calendar.MONTH,1 ) ;
calendar.add ( Calendar.DAY_OF_MONTH,-1 ) ;
System.out.println ( "End Date" + calendar.getTime ( ) ) ;
protected Calendar(TimeZone zone,
Locale aLocale)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final void clear()
- See Also:
clear(int)
, isSet()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1331]Behaviour of Calendar Clear
By Anonymous on 2005/03/08 14:21:22 Rate
After the 'clear ( ) ' is called, the time value of this Calendar is
undefined as stated in the JavaDoc. You need to call BOTH clear
( Calendar.HOUR ) AND clear ( Calendar.HOUR_OF_DAY ) to reliably set the
time portion of a Calendar object to 0:0:0.0, calling only one of
these is insufficient.
public final void clear(int field)
- See Also:
clear()
, set(Calendar.HOUR_OF_DAY, 0)
, AM_PM
, HOUR
, HOUR_OF_DAY
, isSet(field)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Object clone()
- See Also:
Cloneable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int compareTo(Calendar anotherCalendar)
- See Also:
- IllegalArgumentException, NullPointerException, Comparable, compareTo
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void complete()
- See Also:
computeFields()
, computeTime()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected abstract void computeFields()
- See Also:
computeTime()
, complete()
, fields[]
, time
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected abstract void computeTime()
- See Also:
computeFields()
, complete()
, time
, fields[]
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DATE
- See Also:
DAY_OF_MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DAY_OF_MONTH
- See Also:
DATE
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[625]Calculate No. of days in a month
By Babu on 2005/01/19 06:33:11 Rate
Calendar Today = new GregorianCalendar ( ) ;
System.out.println ( "No. of days in this month = " + Today.getActualMaximum ( Calendar.DAY_OF_MONTH ) ) ;
[917]Month is Zero-Based
By Harischandra Valisetty on 2004/09/22 03:07:48 Rate
Month is Zero-Based. E.g., January is 0 and December is 11
public static final int DAY_OF_WEEK
- See Also:
SATURDAY
, FRIDAY
, THURSDAY
, WEDNESDAY
, TUESDAY
, MONDAY
, SUNDAY
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1805]Retrieving the DAY_OF_WEEK from a Calendar object
By Anonymous on 2006/08/09 17:55:28 Rate
int currentDayOfWeek = Calendar.getInstance ( ) .get ( Calendar.DAY_OF_WEEK ) ;
public static final int DAY_OF_WEEK_IN_MONTH
- See Also:
WEEK_OF_MONTH
, DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DAY_OF_YEAR
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DECEMBER
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int DST_OFFSET
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean equals(Object obj)
- See Also:
Hashtable
, Object.hashCode()
, compareTo
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int ERA
- See Also:
GregorianCalendar.BC
, GregorianCalendar.AD
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int FEBRUARY
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected int[] fields
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int FIELD_COUNT
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int FRIDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1378]FRIDAY value
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:19:40 Rate
System.out.println ( "In current Year, this week's FRIDAY is the " + Calendar.FRIDAY + "th" ) ;
public int get(int field)
- See Also:
complete()
, set(int,int)
, ArrayIndexOutOfBoundsException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getActualMaximum(int field)
- See Also:
getActualMinimum(int)
, getLeastMaximum(int)
, getGreatestMinimum(int)
, getMaximum(int)
, getMinimum(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[626]Calculate No. of days in a year
By Babu on 2004/01/23 09:12:14 Rate
Calendar Today = new GregorianCalendar ( ) ;
System.out.println ( "No. of days in this month = " + Today.getActualMaximum ( Calendar.DAY_OF_MONTH ) ) ;
System.out.println ( "No. of days in this year = " + Today.getActualMaximum ( Calendar.DAY_OF_YEAR ) ) ;
[1128]Chack validity of a date
By Khurram Chaudhry on 2004/11/19 21:49:14 Rate
Chack validity of a date
public boolean isDateValid ( GregorianCalendar c )
{
if ( ( c.getActualMaximum ( GregorianCalendar.MONTH )
< c.get ( GregorianCalendar.MONTH ) )
|| ( c.getActualMaximum ( GregorianCalendar.DAY_OF_MONTH )
< c.get ( GregorianCalendar.DAY_OF_MONTH ) )
|| ( c.getActualMaximum ( GregorianCalendar.YEAR )
< c.get ( GregorianCalendar.YEAR ) ) )
{
return false;
}
return true;
}
public int getActualMinimum(int field)
- See Also:
getActualMaximum(int)
, getLeastMaximum(int)
, getGreatestMinimum(int)
, getMaximum(int)
, getMinimum(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static Locale[] getAvailableLocales()
- See Also:
Locale.US
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getFirstDayOfWeek()
- See Also:
getMinimalDaysInFirstWeek()
, setFirstDayOfWeek(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[436]Get First Day Of Week
By kabelbacha { at } airfrance { dot } fr on 2005/02/23 21:29:35 Rate
GregorianCalendar now = new GregorianCalendar ( an,mois,1 ) ;
int days= now.getActualMaximum ( Calendar.DAY_OF_MONTH ) ;
int jj=now.getFirstDayOfWeek ( ) ;
public abstract int getGreatestMinimum(int field)
- See Also:
getActualMaximum(int)
, getActualMinimum(int)
, getLeastMaximum(int)
, getMaximum(int)
, getMinimum(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static Calendar getInstance()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1704]Doesn't return time; it returns GMT offset
By sean { dot } kenney { at } qwest { dot } com on 2006/01/25 11:41:34 Rate
The getInstance method does not return a time; it returns the time
offset from GMT. I'm in the Pacific time zone, so my call to this
method returns 2006-01-25-08:00 since I am 8:00 hours behind GMT.
public static Calendar getInstance(Locale aLocale)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static Calendar getInstance(TimeZone zone)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[301]Set calendar to specific date
By Anonymous on 2003/07/08 17:37:44 Rate
Calendar admitCal = Calendar.getInstance ( ) ;
admitCal.set ( 2002, 2, 2 ) ;
public static Calendar getInstance(TimeZone zone,
Locale aLocale)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract int getLeastMaximum(int field)
- See Also:
getActualMaximum(int)
, getActualMinimum(int)
, getGreatestMinimum(int)
, getMaximum(int)
, getMinimum(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract int getMaximum(int field)
- See Also:
getActualMaximum(int)
, getActualMinimum(int)
, getLeastMaximum(int)
, getGreatestMinimum(int)
, getMinimum(int)
, get
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMinimalDaysInFirstWeek()
- See Also:
setMinimalDaysInFirstWeek(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract int getMinimum(int field)
- See Also:
getActualMaximum(int)
, getActualMinimum(int)
, getLeastMaximum(int)
, getGreatestMinimum(int)
, getMaximum(int)
, get
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final Date getTime()
- See Also:
getTimeInMillis()
, setTime(Date)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[399]Get time of specific time zone
By Anonymous on 2004/11/15 09:04:49 Rate
public Date getTime ( ) {
TimeZone zone = TimeZone.getTimeZone ( "GMT+0" ) ;
Calendar calendar = Calendar.getInstance ( zone ) ;
return calendar.getTime ( ) ;
}
public long getTimeInMillis()
- See Also:
setTimeInMillis(long)
, getTime()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public TimeZone getTimeZone()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int hashCode()
- See Also:
Hashtable
, Object.equals(java.lang.Object)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int HOUR
- See Also:
AM_PM
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int HOUR_OF_DAY
- See Also:
HOUR
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1379]Get current hour of the day
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:32:11 Rate
Calendar expires = new GregorianCalendar ( ) ;
System.out.println ( " The current hour of the day is " + expires.HOUR_OF_DAY ) ;
protected final int internalGet(int field)
- See Also:
get(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isLenient()
- See Also:
setLenient(boolean)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean[] isSet
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final boolean isSet(int field)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean isTimeSet
- See Also:
time
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int JANUARY
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int JULY
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int JUNE
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MARCH
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MAY
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MILLISECOND
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MINUTE
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MONDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1374]In current Year, check out this week MONDAY
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:17:36 Rate
System.out.println ( "In current Year, this week's MONDAY is the " + Calendar.MONDAY + "th" ) ;
public static final int MONTH
- See Also:
UNDECIMBER
, DECEMBER
, NOVEMBER
, OCTOBER
, SEPTEMBER
, AUGUST
, JULY
, JUNE
, MAY
, APRIL
, MARCH
, FEBRUARY
, JANUARY
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int NOVEMBER
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int OCTOBER
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int PM
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void roll(int field,
boolean up)
- See Also:
set(int,int)
, add(int,int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void roll(int field,
int amount)
- See Also:
set(int,int)
, add(int,int)
, roll(int,boolean)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int SATURDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1372]SATURDAY
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:16:00 Rate
Calendar expires = new GregorianCalendar ( ) ;
System.out.println ( "In current Year, this week's SATURDAY is the " + Calendar.SATURDAY + "th" ) ;
public static final int SECOND
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int SEPTEMBER
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void set(int field,
int value)
- See Also:
get(int)
, set(int,int,int,int,int,int)
, set(int,int,int,int,int)
, set(int,int,int)
, ArrayIndexOutOfBoundsException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final void set(int year,
int month,
int date)
- See Also:
set(int,int,int,int,int,int)
, set(int,int,int,int,int)
, set(int,int)
, clear()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final void set(int year,
int month,
int date,
int hourOfDay,
int minute)
- See Also:
set(int,int,int,int,int,int)
, set(int,int,int)
, set(int,int)
, clear()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final void set(int year,
int month,
int date,
int hourOfDay,
int minute,
int second)
- See Also:
set(int,int,int,int,int)
, set(int,int,int)
, set(int,int)
, clear()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setFirstDayOfWeek(int value)
- See Also:
getMinimalDaysInFirstWeek()
, getFirstDayOfWeek()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setLenient(boolean lenient)
- See Also:
isLenient()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setMinimalDaysInFirstWeek(int value)
- See Also:
getMinimalDaysInFirstWeek()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final void setTime(Date date)
- See Also:
setTimeInMillis(long)
, getTime()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[84]Set the time of a calendar
By Anonymous on 2003/08/15 16:32:04 Rate
GregorianCalendar calendar = new GregorianCalendar ( ) ;
calendar.setTime ( date ) ;
[850]Format a date to MM/dd/yyyy
By david wang (lwang10 { at } yahoo { dot } com) on 2004/10/08 13:00:41 Rate
String notifyDates = "8/3/2004";
Calendar calendar = Calendar.getInstance ( ) ;
DateFormat dateFormat = new SimpleDateFormat ( "MM/dd/yyyy" ) ;
try {
Date date = dateFormat.parse ( notifyDates ) ;
calendar.setTime ( date ) ;
System.out.println ( "The initial date is : " + dateFormat.format ( calendar.getTime ( ) ) ) ;
calendar.add ( Calendar.DATE, 30 ) ;
System.out.println ( "The date in 30 days is : " + dateFormat.format ( calendar.getTime ( ) ) ) ;
} catch ( Exception e ) {
e.printStackTrace ( ) ;
}
[1095]Roll a Calendar day
By Anonymous on 2004/11/04 12:39:02 Rate
Calendar expires = new GregorianCalendar ( ) ;
DateFormat df = DateFormat.getDateInstance ( DateFormat.SHORT ) ;
expires.setTime ( df.parse ( "11/6/2004" ) ) ;
Calendar now = new GregorianCalendar ( ) ;
now.setTime ( new Date ( ) ) ;
now.roll ( Calendar.DAY_OF_YEAR, 3 ) ;
if ( expires.before ( now ) )
System.out.println ( "Hit it" ) ;
public void setTimeInMillis(long millis)
- See Also:
getTimeInMillis()
, setTime(Date)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[404]_
By Anonymous on 2003/09/19 10:17:45 Rate
GregorianCalendar calendar = new GregorianCalendar ( ) ;
calendar.setTimeInMillis ( 1063980997023 ) ;
[1318]Load current time
By Bruce Ingalls on 2005/02/24 18:30:09 Rate
//load current time
currentDate.setTimeInMillis ( System.currentTimeMillis ( ) ) ;
public void setTimeZone(TimeZone value)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int SUNDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1373]_
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:17:03 Rate
System.out.println ( "In current Year, this week's SUNDAY is the " + Calendar.SUNDAY+ "th" ) ;
public static final int THURSDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1377]_
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:19:08 Rate
System.out.println ( "In current Year, this week's THURSDAY is the " + Calendar.THURSDAY + "th" ) ;
protected long time
- See Also:
isTimeSet
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String toString()
- See Also:
- Object
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int TUESDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1375]_
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:18:21 Rate
System.out.println ( "In current Year, this week's TUESDAY is the " + Calendar.TUESDAY + "th" ) ;
public static final int UNDECIMBER
- See Also:
MONTH
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int WEDNESDAY
- See Also:
DAY_OF_WEEK
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1376]_
By sapna_308 { at } yahoo { dot } com on 2005/04/05 11:18:44 Rate
System.out.println ( "In current Year, this week's WEDNESDAY is the " + Calendar.WEDNESDAY + "th" ) ;
public static final int WEEK_OF_MONTH
- See Also:
getMinimalDaysInFirstWeek()
, getFirstDayOfWeek()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[773]Week of month
By Karthikeyan M on 2004/05/10 23:48:32 Rate
Calendar cal = GregorianCalendar.getInstance ( ) ;
int week = cal.get ( Calendar.WEEK_OF_MONTH ) ;
System.out.println ( "Week="+week+" Date="+cal.getTime ( ) ) ;
Calendar calendar = new GregorianCalendar ( ) ;
calendar.set ( Calendar.WEEK_OF_MONTH, 4 ) ; // pass a valid week
System.out.println ( "Date =" + calendar.getTime ( ) ) ;
public static final int WEEK_OF_YEAR
- See Also:
getMinimalDaysInFirstWeek()
, getFirstDayOfWeek()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[887]Week of year
By Arpit Rai on 2004/09/07 17:38:33 Rate
Calendar cal = Calendar.getInstance ( ) ;
int week = cal.get ( Calendar.WEEK_OF_YEAR ) ;
System.out.println ( "Week="+week ) ;
public static final int YEAR
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[377]Calendar year
By Anonymous on 2004/11/10 15:17:10 Rate
Calendar cal = GregorianCalendar.getInstance ( ) ;
int year = cal.get ( Calendar.YEAR ) ; // 2003
[709]_
By Virgilio So (Jan So) on 2004/04/02 09:13:26 Rate
Calendar calendar = new GregorianCalendar ( ) ;
calendar.setTime ( date ) ; // pass a valid date here
System.out.println ( "Year is " + calendar.YEAR ) ;
public static final int ZONE_OFFSET
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[128]Get the zone offset in hours
By Anonymous on 2003/08/29 13:01:25 Rate
// Get the zone offset in hours
int zone_offset = now.get ( Calendar.ZONE_OFFSET ) / ( 60 * 60 * 1000 ) ;