Example usage for java.util Calendar getClass

List of usage examples for java.util Calendar getClass

Introduction

In this page you can find the example usage for java.util Calendar getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:CalCalcs.java

public static void main(String[] argv) {
    //+/*  w  ww.j a  v  a  2 s.  c o m*/
    Calendar c = Calendar.getInstance();
    System.out.println("I got a " + c.getClass());
    c.set(1951, 03, 24, 12, 30, 0);
    System.out.println("I set it to " + c.getTime().toString());
    System.out.println("I actually set the year to " + c.get(Calendar.YEAR));
    System.out.println("In milliseconds, that's " + c.getTime().getTime());
    System.out.println("Or, in seconds, " + c.getTime().getTime() / 1000);
    //-
}

From source file:JapaneseCalendar.java

public static void main(String args[]) {
    Locale locale = new Locale("ja", "JP", "JP");
    Calendar now = Calendar.getInstance(locale);

    Map<String, Integer> names = now.getDisplayNames(Calendar.ERA, Calendar.LONG, locale);
    System.out.printf("%s%n", names);
    System.out.printf("It is year %tY of the current era%n", now);
    System.out.printf("The calendar class is: %s%n", now.getClass().getName());
}

From source file:Main.java

/**
 * <p>Checks if two calendar objects represent the same local time.</p>
 *
 * <p>This method compares the values of the fields of the two objects.
 * In addition, both calendars must be the same of the same type.</p>
 * /*www  .  j  a  va  2  s . c o m*/
 * @param cal1  the first calendar, not altered, not null
 * @param cal2  the second calendar, not altered, not null
 * @return true if they represent the same millisecond instant
 * @throws IllegalArgumentException if either date is <code>null</code>
 * @since 2.1
 */
public static boolean isSameLocalTime(Calendar cal1, Calendar cal2) {
    if (cal1 == null || cal2 == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND)
            && cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND)
            && cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE)
            && cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR)
            && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)
            && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
            && cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.getClass() == cal2.getClass());
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithCalendarArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Calendar calendarValue = config.calendarArray[0];

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithCalendarArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Calendar calendarValue = config.calendarArray[0];

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithCalendarList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Calendar calendarValue = config.calendarList.get(0);

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarList.size());
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationXMLWithCalendarList() {
    ConfigurationXMLWithList config = prepareConfigurationXMLWithList();

    Calendar calendarValue = config.calendarList.get(0);

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarList.size());
}

From source file:org.apache.openjpa.util.ProxyManagerImpl.java

public Calendar copyCalendar(Calendar orig) {
    if (orig == null)
        return null;
    if (orig instanceof Proxy)
        return (Calendar) ((Proxy) orig).copy(orig);

    ProxyCalendar proxy = getFactoryProxyCalendar(orig.getClass());
    return (Calendar) proxy.copy(orig);
}