Example usage for java.util GregorianCalendar setTimeZone

List of usage examples for java.util GregorianCalendar setTimeZone

Introduction

In this page you can find the example usage for java.util GregorianCalendar setTimeZone.

Prototype

@Override
    public void setTimeZone(TimeZone zone) 

Source Link

Usage

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

/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 *//*from www .j a  va2  s. com*/
@Test
public void testGetLastMillisecondWithCalendar() {
    Second s = new Second(50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550999L, s.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        s.getLastMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *///from  www.j a  v a 2  s  .  c  o m
@Test
public void testGetFirstMillisecondWithCalendar() {
    Minute m = new Minute(40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766400000L, m.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 *//*from   www  .j a  v a  2s.c o  m*/
@Test
public void testGetLastMillisecondWithCalendar() {
    Minute m = new Minute(45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889559999L, m.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *//*from  w  w w  .ja  v  a2s.c  om*/
@Test
public void testGetFirstMillisecondWithCalendar() {
    Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766455500L, m.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 *//*from  w w  w  .  j a  v a2s.  com*/
@Test
public void testGetLastMillisecondWithCalendar() {
    Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550250L, m.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getLastMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:RolloverFileOutputStream.java

public RolloverFileOutputStream(String filename, boolean append, int retainDays, TimeZone zone)
        throws IOException {
    super(null);/*from  www .  j  a va2 s .c  o m*/

    _fileBackupFormat.setTimeZone(zone);
    _fileDateFormat.setTimeZone(zone);

    if (filename != null) {
        filename = filename.trim();
        if (filename.length() == 0)
            filename = null;
    }
    if (filename == null)
        throw new IllegalArgumentException("Invalid filename");

    _filename = filename;
    _append = append;
    _retainDays = retainDays;
    setFile();

    synchronized (RolloverFileOutputStream.class) {
        if (__rollover == null)
            __rollover = new Timer();

        _rollTask = new RollTask();

        Calendar now = Calendar.getInstance();
        now.setTimeZone(zone);

        GregorianCalendar midnight = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
                now.get(Calendar.DAY_OF_MONTH), 23, 0);
        midnight.setTimeZone(zone);
        midnight.add(Calendar.HOUR, 1);
        __rollover.scheduleAtFixedRate(_rollTask, midnight.getTime(), 1000L * 60 * 60 * 24);
    }
}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *//*from  ww  w.  ja v  a2 s  . c  om*/
public void testGetFirstMillisecondWithCalendar() {
    Second s = new Second(55, 40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766455000L, s.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        s.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

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

/**
 * Some checks for the getLastMillisecond(TimeZone) method.
 *///from  w w  w  .j a v  a2 s  .  c  o  m
public void testGetLastMillisecondWithCalendar() {
    Second s = new Second(50, 45, 21, 21, 4, 2001);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(987889550999L, s.getLastMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        s.getLastMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.GmdConverter.java

protected void addIdentificationInfo(MetacardImpl metacard, XstreamPathValueTracker pathValueTracker) {

    pathValueTracker.add(new Path(GmdMetacardType.TITLE_PATH), StringUtils.defaultString(metacard.getTitle()));

    GregorianCalendar createdCal = new GregorianCalendar();

    if (metacard.getCreatedDate() != null) {

        createdCal.setTime(metacard.getCreatedDate());
    }/*w w  w  . ja  v a2s .  c  o  m*/
    createdCal.setTimeZone(UTC_TIME_ZONE);
    pathValueTracker.add(new Path(GmdMetacardType.CREATED_DATE_PATH),
            XSD_FACTORY.newXMLGregorianCalendar(createdCal).toXMLFormat());

    pathValueTracker.add(new Path(GmdMetacardType.CREATED_DATE_TYPE_CODE_PATH), GmdMetacardType.METACARD_URI);
    pathValueTracker.add(new Path(GmdMetacardType.CREATED_DATE_TYPE_CODE_VALUE_PATH), Metacard.CREATED);

    pathValueTracker.add(new Path(GmdMetacardType.ABSTRACT_PATH),
            StringUtils.defaultString(metacard.getDescription()));
    pathValueTracker.add(new Path(GmdMetacardType.POINT_OF_CONTACT_PATH),
            StringUtils.defaultString(metacard.getPointOfContact()));

    pathValueTracker.add(new Path(GmdMetacardType.POINT_OF_CONTACT_ROLE_PATH), (String) null);

    pathValueTracker.add(new Path(GmdMetacardType.LANGUAGE_PATH),
            StringUtils.defaultIfEmpty(Locale.getDefault().getLanguage(), Locale.ENGLISH.getLanguage()));
    addExtent(metacard, pathValueTracker);

}

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

/**
 * Some checks for the getFirstMillisecond(TimeZone) method.
 *///from   www . j  a  v a 2  s .  c  om
public void testGetFirstMillisecondWithCalendar() {
    Minute m = new Minute(40, 2, 15, 4, 2000);
    GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
    calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
    assertEquals(955766400000L, m.getFirstMillisecond(calendar));

    // try null calendar
    boolean pass = false;
    try {
        m.getFirstMillisecond((Calendar) null);
    } catch (NullPointerException e) {
        pass = true;
    }
    assertTrue(pass);
}