Example usage for java.util Calendar JANUARY

List of usage examples for java.util Calendar JANUARY

Introduction

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

Prototype

int JANUARY

To view the source code for java.util Calendar JANUARY.

Click Source Link

Document

Value of the #MONTH field indicating the first month of the year in the Gregorian and Julian calendars.

Usage

From source file:org.codekaizen.vtj.text.BpDateFormatTest.java

/**
 * DOCUMENT ME!//from  w  w  w.  ja v a2s .c o m
 */
public void testIsoFormatting() {
    BpDateFormat fmt1 = null;
    String str1 = null;
    Calendar cal = Calendar.getInstance();

    if (!cal.getTimeZone().getID().equals("America/Chicago")) {
        cal.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
        cal.clear();
    }

    cal.set(2002, Calendar.JANUARY, 2, 8, 16, 44);
    cal.set(Calendar.MILLISECOND, 18);

    fmt1 = new BpDateFormat(BpDateFormat.ISO_DATE_ONLY, Locale.US);
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-01-02", str1);

    fmt1 = new BpDateFormat(BpDateFormat.ISO_YEAR_WEEK, Locale.US);
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-W01", str1);

    fmt1 = new BpDateFormat(BpDateFormat.ISO_TIME_ONLY, Locale.US);
    str1 = fmt1.format(cal.getTime());
    assertEquals("T08:16:44", str1);

    fmt1 = new BpDateFormat(BpDateFormat.ISO_DATE_TIME, Locale.US);
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-01-02T08:16:44.018-06:00", str1);

    cal.set(Calendar.MONTH, Calendar.JUNE);
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-06-02T08:16:44.018-05:00", str1);

    cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    cal.set(2002, Calendar.JANUARY, 2, 8, 16, 44);
    cal.set(Calendar.MILLISECOND, 18);
    fmt1.setTimeZone(TimeZone.getTimeZone("UTC"));
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-01-02T08:16:44.018Z", str1);

    cal.set(Calendar.MONTH, Calendar.JUNE);
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-06-02T08:16:44.018Z", str1);

    cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tehran"));
    cal.set(2002, Calendar.JANUARY, 2, 8, 16, 44);
    cal.set(Calendar.MILLISECOND, 18);
    fmt1.setTimeZone(TimeZone.getTimeZone("Asia/Tehran"));
    str1 = fmt1.format(cal.getTime());
    assertEquals("2002-01-02T08:16:44.018+03:30", str1);

}

From source file:com.jaspersoft.jasperserver.test.CoreDataCreateTestNG.java

private void addSchedulerResources() {
    final HolidayCalendar holidayCalendar = new HolidayCalendar();

    Calendar calendar = new GregorianCalendar(2012, Calendar.JANUARY, 1);
    for (int year = 2012; year <= 2022; year++) {
        calendar.set(Calendar.YEAR, year);
        holidayCalendar.addExcludedDate(calendar.getTime());
    }/*from  w  w  w .  j  av  a 2  s.c  om*/

    holidayCalendar.setTimeZone(TimeZone.getDefault());
    holidayCalendar.setDescription(HOLIDAY_CALENDAR_NAME);
    getReportScheduler().addCalendar(HOLIDAY_CALENDAR_NAME, holidayCalendar, true, true);
}

From source file:com.xing.api.JsonSerializationTest.java

@NonNull
private static Company buildPrimaryCompany() {
    return new Company().id("1_abcdef").name("XING AG").title("Softwareentwickler")
            .companySize(CompanySize.SIZE_201_500).url("http://www.xing.com")
            .careerLevel(CareerLevel.PROFESSIONAL_EXPERIENCED)
            .beginDate(new SafeCalendar(2010, Calendar.JANUARY))
            .industries(Collections.singletonList(new Industry(90700, "Internet and online media")))
            .formOfEmployment(FormOfEmployment.FULL_TIME_EMPLOYEE).untilNow(true)
            .discipline(new Discipline("12_05e01e", "IT_AND_SOFTWARE_DEVELOPMENT"));
}

From source file:helper.lang.DateHelperTest.java

@Test
public void testDiffAndConversionsDifferentDate() {
    Calendar cal1 = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
    Calendar cal2 = new GregorianCalendar(1999, Calendar.JANUARY, 1);
    long diffMillis = DateHelper.diffInMillis(cal1.getTimeInMillis(), cal2.getTimeInMillis());

    assertEquals(604800000L, diffMillis);
    assertEquals(604800L, DateHelper.millisToSeconds(diffMillis));
    assertEquals(10080, DateHelper.millisToMinutes(diffMillis));
    assertEquals(168, DateHelper.millisToHours(diffMillis));
    assertEquals(7, DateHelper.millisToDays(diffMillis));
}

From source file:br.msf.commons.util.AbstractDateUtils.java

public static void main(String[] args) {
    Age age;//  w w  w  . j a  va2  s.co  m
    Calendar c1, c2;

    c1 = new GregorianCalendar(2012, Calendar.JANUARY, 1);
    c2 = new GregorianCalendar(2012, Calendar.JANUARY, 1);
    age = getAge(c1, c2);
    System.out.println(age);

    c1 = new GregorianCalendar(2012, Calendar.JANUARY, 1);
    c2 = new GregorianCalendar(2012, Calendar.FEBRUARY, 1);
    age = getAge(c1, c2);
    System.out.println(age);

    c1 = new GregorianCalendar(2012, Calendar.JANUARY, 1);
    c2 = Calendar.getInstance();
    age = getAge(c1, c2);
    System.out.println(age);
}

From source file:org.jfree.data.time.YearTest.java

/**
 * Some checks for the getStart() method.
 */// w w w. j av a  2 s. c o m
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Year y = new Year(2006);
    assertEquals(cal.getTime(), y.getStart());
    Locale.setDefault(saved);
}

From source file:org.jfree.data.time.HourTest.java

/**
 * Some checks for the getStart() method.
 *///  ww  w.  java2  s.co m
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Hour h = new Hour(3, 16, 1, 2006);
    assertEquals(cal.getTime(), h.getStart());
    Locale.setDefault(saved);
}

From source file:org.jfree.data.time.junit.MinuteTest.java

/**
 * Some checks for the getStart() method.
 */// w  ww .  ja  va  2 s  .  co m
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome"));
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Minute m = new Minute(47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), m.getStart());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:org.jfree.data.time.junit.SecondTest.java

/**
 * Some checks for the getStart() method.
 *//* w w  w  .j ava  2 s  .  c  om*/
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 0);
    Second s = new Second(55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), s.getStart());
    Locale.setDefault(saved);
}

From source file:org.jfree.data.time.MillisecondTest.java

/**
 * Some checks for the getStart() method.
 *///from   w  w  w.ja  v  a  2  s .c o  m
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 555);
    Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), m.getStart());
    Locale.setDefault(saved);
}