Java 类java.util.Calendar.Builder 实例源码

项目:boundary-event-sdk    文件:ScriptRouteBuilderTest.java   
@Override
public void setUp() throws Exception {
    super.setUp();

    Builder dtBuilder = new Calendar.Builder();
    Calendar cal = dtBuilder.build();
    this.now = cal.getTime();

    SyslogMessage syslogMessage = new SyslogMessage();
    syslogMessage.setFacility(SyslogFacility.FTP);
    syslogMessage.setHostname("myweb.com");
    syslogMessage.setLocalAddress("172.16.0.1");
    syslogMessage.setLogMessage("myweb.com not responding to ping");
    syslogMessage.setRemoteAddress("10.10.62.36");
    syslogMessage.setSeverity(SyslogSeverity.EMERG);
    syslogMessage.setTimestamp(cal);

    syslogMessageEvent = new SyslogMessageEvent(syslogMessage);

}
项目:boundary-event-sdk    文件:EventCLITest.java   
@Ignore
@Test
public void testParseDateTime_1() throws java.text.ParseException {
    Builder builder = new Calendar.Builder();
    builder.setTimeZone(TimeZone.getTimeZone("GMT"));

    builder.setDate(2010, 0, 5);
    builder.setTimeOfDay(22, 22, 22);
    Date expectedISODate = builder.build().getTime();

    builder.setDate(2006, 3, 6);
    builder.setTimeOfDay(14, 22, 22);
    Date expectedDate = builder.build().getTime();

    String iso = "2010-01-05T14:22:22";
    Date parsedISODate = cli.parseDateTime(iso);
    assertEquals("check parsed ISO Date Time",expectedISODate,parsedISODate);

    String s = "2006-04-06 14:22:22";
    Date parsedDate = cli.parseDateTime(s);
    assertEquals("check parsed Date Time",expectedDate,parsedDate);
}
项目:boundary-event-sdk    文件:EsperRouteTest.java   
@Ignore
@Test
public void testQueryListLoad() throws Exception {
    EsperRouteBuilder builder = new EsperRouteBuilder();
    builder.setConfiguration("test-esper-route-query-load.json");
    builder.loadConfiguration();
    QueryList queryList = builder.getQueryList();
    List<Query> qlist = queryList.getQueries();
    assertEquals("test query list count",3,queryList.getQueries().size());

    Query query1 = qlist.get(0);
    Builder build = new Calendar.Builder();
    build.setTimeZone(TimeZone.getTimeZone("GMT"));
    build.setDate(2015,0,27);
    build.setTimeOfDay(0, 0, 0, 0);
    Calendar cal = build.build();
    assertEquals("check query 1 name","red",query1.getName());
    assertEquals("check query 1 create",cal.getTime(),query1.getCreated());
    assertEquals("check query 1 enabled",true,query1.isEnabled());
    assertEquals("check query 1 description","Red description",query1.getDescription());
    assertEquals("check query 1 query",
            "select * from Red where name = 'ONE' and property = 2",query1.getQuery());
}
项目:KicksEmu    文件:DateUtils.java   
public static Date buildTimeOfDay(int hour, int minute, int seconds) {
    return new Builder().setTimeOfDay(hour, minute, seconds).build().getTime();
}
项目:boundary-event-sdk    文件:ScriptRouteBuilderTest.java   
@Test
public void testScriptEvent() throws InterruptedException {
    Builder builder = new Calendar.Builder();
    builder.setDate(2010, 5, 20);
    builder.setTimeOfDay(13, 0, 0,0);
    Calendar cal = builder.build();

    out.expectedMessageCount(1);
    ScriptEvent event = new ScriptEvent();

    out.getExchanges();
    in.sendBodyAndHeaders(event,setScriptHeader("classpath:META-INF/js/test-script-event.js"));
    out.assertIsSatisfied();

    List<Exchange> exchanges = out.getExchanges();
    assertEquals("check exchange count",1,exchanges.size());
    Exchange exchange = exchanges.get(0);
    Message message = exchange.getIn();
    ScriptEvent newEvent = message.getBody(ScriptEvent.class);
    assertNotNull("check for not null",newEvent);

    Map<String,Object> map = new HashMap<String,Object>();
    map.put("red", "one");
    map.put("green","two");
    map.put("blue","three");

    List<String> list = new ArrayList<String>();
    list.add("alex");
    list.add("geddy");
    list.add("neal");

    ScriptEnum enumeration = ScriptEnum.YELLOW;

    ScriptObject object = new ScriptObject();
    object.setDate(cal.getTime());
    object.setString("Goodbye");
    object.setList(list);
    object.setMap(map);

    assertEquals("check date",cal.getTime(),newEvent.getDate());
    assertEquals("check string","Hello World!",newEvent.getString());
    assertEquals("check int",37,newEvent.getInteger());
    assertEquals("check decimal",9.81,newEvent.getDecimal(),DELTA);
    assertEquals("check map",map,newEvent.getMap());
    assertEquals("check list",list,newEvent.getList());
    assertEquals("check enumeration",enumeration,newEvent.getEnumeration());
    assertEquals("check object",object,newEvent.getObject());

}
项目:boundary-event-sdk    文件:SyslogToEventProcessorTest.java   
@Before
public void setUp() throws Exception {
    Date now = new Date();
    super.setUp();
    Builder builder = new Calendar.Builder();
    builder.setInstant(now);

    syslogMessage = buildSyslogMessage(
            EXPECTED_SYSLOG_FACILITY,
            EXPECTED_HOST,
            EXPECTED_LOCAL_ADDRESS,
            EXPECTED_LOG_MESSAGE,
            EXPECTED_REMOTE_ADDRESS,
            EXPECTED_SYSLOG_SEVERITY,
            builder.build());

    event = new RawEvent();


    event.addTag(SyslogFacility.DAEMON.toString());
    event.getSource().setRef(EXPECTED_HOST).setType(EXPECTED_SOURCE_TYPE);
    event.addTag(EXPECTED_SYSLOG_FACILITY.toString());
    event.addTag(EXPECTED_HOST);
    event.setCreatedAt(now);
    event.addFingerprintField("facility");
    event.addFingerprintField("hostname");
    event.addFingerprintField("message");
    event.setTitle(String.format("Syslog message from: %s",EXPECTED_HOST));
    event.setMessage(EXPECTED_LOG_MESSAGE);

    expectedTags = new ArrayList<String>();
    expectedTags.add(SyslogFacility.DAEMON.toString());
    expectedTags.add(EXPECTED_HOST);

    expectedProperties = new HashMap<String,Object>();
    expectedProperties.put("facility",SyslogFacility.DAEMON.toString());
    expectedProperties.put("hostname",EXPECTED_HOST);
    expectedProperties.put("message",EXPECTED_LOG_MESSAGE);

    expectedFingerprintFields = new ArrayList<String>();
    expectedFingerprintFields.add("facility");
    expectedFingerprintFields.add("hostname");
    expectedFingerprintFields.add("message");
}
项目:boundary-event-sdk    文件:QueryListTest.java   
@Test
public void test() {
    Query query1 = queryList.getQueries().get(0);
    Builder build1 = new Calendar.Builder();
    build1.setTimeZone(TimeZone.getTimeZone("GMT"));
    build1.setDate(2015,0,27);
    build1.setTimeOfDay(0, 0, 0, 0);
    Calendar cal1 = build1.build();
    assertEquals("check query 1 name","red",query1.getName());
    assertEquals("check query 1 create",cal1.getTime(),query1.getCreated());
    assertEquals("check query 1 modified",cal1.getTime(),query1.getModified());
    assertEquals("check query 1 enabled",true,query1.isEnabled());
    assertEquals("check query 1 description","Red description",query1.getDescription());
    assertEquals("check query 1 query",
            "select * from Red where name = 'ONE' and property = 2",query1.getQuery());

    Query query2 = queryList.getQueries().get(1);
    Builder build2 = new Calendar.Builder();
    build2.setTimeZone(TimeZone.getTimeZone("GMT"));
    build2.setDate(1992,5,20);
    build2.setTimeOfDay(0, 0, 0, 0);
    Calendar cal2 = build2.build();
    assertEquals("check query 2 name","blue",query2.getName());
    assertEquals("check query 2 create",cal2.getTime(),query2.getCreated());
    assertEquals("check query 2 modified",cal2.getTime(),query2.getCreated());
    assertEquals("check query 2 enabled",false,query2.isEnabled());
    assertEquals("check query 2 description","Blue description",query2.getDescription());
    assertEquals("check query 2 query",
            "select * from Blue where name = 'ONE' and property = 2",query2.getQuery());

    Query query3 = queryList.getQueries().get(2);
    Builder build3 = new Calendar.Builder();
    build3.setTimeZone(TimeZone.getTimeZone("GMT"));
    build3.setDate(2000,11,10);
    build3.setTimeOfDay(0, 0, 0, 0);
    Calendar cal3 = build3.build();
    assertEquals("check query 3 name","green",query3.getName());
    assertEquals("check query 3 create",cal3.getTime(),query3.getCreated());
    assertEquals("check query 3 enabled",true,query3.isEnabled());
    assertEquals("check query 3 description","Green description",query3.getDescription());
    assertEquals("check query 3 query",
            "select * from Green where name = 'ONE' and property = 2",query3.getQuery());

}
项目:OpenJSharp    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}
项目:jdk8u-jdk    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}
项目:jdk8u_jdk    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}
项目:lookaside_java-1.8.0-openjdk    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}
项目:infobip-open-jdk-8    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}
项目:jdk8u-dev-jdk    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}
项目:OLD-OpenJDK8    文件:CalendarProviderImpl.java   
/**
 * Returns a new <code>Calendar</code> instance for the
 * specified locale.
 *
 * @param zone the time zone
 * @param locale the desired locale
 * @exception NullPointerException if <code>locale</code> is null
 * @exception IllegalArgumentException if <code>locale</code> isn't
 *     one of the locales returned from
 *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
 *     getAvailableLocales()}.
 * @return a <code>Calendar</code> instance.
 * @see java.util.Calendar#getInstance(java.util.Locale)
 */
@Override
public Calendar getInstance(TimeZone zone, Locale locale) {
    return new Calendar.Builder()
                 .setLocale(locale)
                 .setTimeZone(zone)
                 .setInstant(System.currentTimeMillis())
                 .build();
}