Java Code Examples for org.joda.time.DateTime

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project apollo, under directory /injector/src/main/java/com/bskyb/cg/environments/message/.

Source file: BaseMessageFormat.java

  19 
vote

protected DateTime parseDate(String datestring) throws java.text.ParseException, IndexOutOfBoundsException {
  DateTimeFormatter df=DateTimeFormat.forPattern(datePattern);
  DateTime d=new DateTime();
  d=df.parseDateTime(datestring);
  return d;
}
 

Example 2

From project Arecibo, under directory /collector/src/main/java/com/ning/arecibo/collector/persistent/.

Source file: TimelineEventHandler.java

  18 
vote

@VisibleForTesting public void processSamples(final HostSamplesForTimestamp hostSamples) throws ExecutionException, IOException {
  final int hostId=hostSamples.getHostId();
  final String category=hostSamples.getCategory();
  final int categoryId=timelineDAO.getEventCategoryId(category);
  final DateTime timestamp=hostSamples.getTimestamp();
  final TimelineHostEventAccumulator accumulator=getOrAddHostEventAccumulator(hostId,categoryId,timestamp);
  accumulator.addHostSamples(hostSamples);
}
 

Example 3

From project Arecibo, under directory /collector/src/test/java/com/ning/arecibo/collector/persistent/.

Source file: TestTimelineAggregator.java

  18 
vote

private void createAOneHourTimelineChunk(final int startTimeMinutesAgo) throws IOException {
  final DateTime firstSampleTime=START_TIME.minusMinutes(startTimeMinutesAgo);
  final TimelineHostEventAccumulator accumulator=new TimelineHostEventAccumulator(timelineDAO,timelineCoder,sampleCoder,hostId,EVENT_TYPE_ID,firstSampleTime);
  for (int i=0; i < 120; i++) {
    final DateTime eventDateTime=firstSampleTime.plusSeconds(i * 30);
    final Map<Integer,ScalarSample> event=createEvent(eventDateTime.getMillis());
    final HostSamplesForTimestamp samples=new HostSamplesForTimestamp(hostId,EVENT_TYPE,eventDateTime,event);
    accumulator.addHostSamples(samples);
  }
  accumulator.extractAndQueueTimelineChunks();
}
 

Example 4

From project ATHENA, under directory /components/reports/src/main/java/org/fracturedatlas/athena/reports/manager/.

Source file: GlanceReporter.java

  18 
vote

private Boolean soldToday(DateTime now,PTicket ticket){
  try {
    DateTime soldAt=DateUtil.parseDateTime(ticket.get("soldAt"));
    return soldAt.isAfter(now.toDateMidnight());
  }
 catch (  Exception e) {
    logger.error("soldAt of ticket [{}] was either null or in incorrect format",ticket.getId());
    logger.error("{}",e.getMessage());
  }
  return false;
}
 

Example 5

From project ATHENA, under directory /components/reports/src/main/java/org/fracturedatlas/athena/reports/manager/.

Source file: GlanceReporter.java

  18 
vote

private Boolean alreadyPlayed(DateTime now,PTicket ticket){
  try {
    DateTime performanceTime=DateUtil.parseDateTime(ticket.get("performance"));
    return performanceTime.isBefore(now);
  }
 catch (  Exception e) {
    logger.error("performance time of ticket [{}] was either null or in incorrect format",ticket.getId());
    logger.error("{}",e.getMessage());
  }
  return false;
}
 

Example 6

From project azkaban, under directory /azkaban/src/java/azkaban/scheduler/.

Source file: ScheduledJob.java

  18 
vote

/** 
 * Updates the time to a future time after 'now' that matches the period description.
 * @return
 */
public boolean updateTime(){
  if (nextScheduledExecution.isAfterNow()) {
    return true;
  }
  if (period != null) {
    DateTime other=getNextRuntime(nextScheduledExecution,period);
    this.nextScheduledExecution=other;
    return true;
  }
  return false;
}
 

Example 7

From project azkaban, under directory /azkaban/src/java/azkaban/scheduler/.

Source file: ScheduleManager.java

  18 
vote

@Override public int compare(ScheduledJob arg0,ScheduledJob arg1){
  DateTime first=arg1.getScheduledExecution();
  DateTime second=arg0.getScheduledExecution();
  if (first.isEqual(second)) {
    return 0;
  }
 else   if (first.isBefore(second)) {
    return 1;
  }
  return -1;
}
 

Example 8

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.

Source file: Utils.java

  18 
vote

public static long calculateNotifTime(Long nowMillis,int hourToNotify){
  DateTime now=new DateTime(nowMillis);
  DateTime timeToNotify=new DateTime(nowMillis);
  timeToNotify=timeToNotify.withHourOfDay(hourToNotify);
  if (timeToNotify.isBefore(now)) {
    timeToNotify=timeToNotify.plusDays(1);
  }
  return timeToNotify.getMillis();
}
 

Example 9

From project Birthday-widget, under directory /Birthday/src/test/java/cz/krtinec/birthday/.

Source file: UtilsTest.java

  18 
vote

@Test public void testCalculateNotifTime(){
  DateTime time=new DateTime();
  time=time.withHourOfDay(8);
  DateTime notifyTime=new DateTime(Utils.calculateNotifTime(time.getMillis(),7));
  assertEquals(1000 * 60 * 60* 23,notifyTime.getMillis() - time.getMillis());
  notifyTime=new DateTime(Utils.calculateNotifTime(time.getMillis(),9));
  assertEquals(1000 * 60 * 60,notifyTime.getMillis() - time.getMillis());
}
 

Example 10

From project c2dm4j, under directory /src/test/java/org/whispercomm/c2dm4j/impl/.

Source file: C2dmHttpResponseHandlerTest.java

  18 
vote

@Test public void parsesUnavailableWithRetryAsSeconds() throws IOException {
  HttpResponse response=buildResponse(503);
  DateTime expected=new DateTime().plusSeconds(42);
  response.setHeader("Retry-After","42");
  Response result=cut.handleResponse(response);
  assertThat(result.getResponseType(),is(ResponseType.ServiceUnavailable));
  assertThat(result.getMessage(),is(message));
  assertThat((result instanceof UnavailableResponse),is(true));
  UnavailableResponse uResult=(UnavailableResponse)result;
  assertThat(uResult.hasRetryAfter(),is(true));
  DateTime retryAfter=new DateTime(uResult.retryAfter());
  assertThat(new Duration(expected,retryAfter).isShorterThan(Duration.standardSeconds(1)),is(true));
}
 

Example 11

From project CalendarPortlet, under directory /src/test/java/org/jasig/portlet/calendar/adapter/.

Source file: CalendarEventDaoTest.java

  18 
vote

@Test public void testGetDisplayEvents() throws IOException, URISyntaxException, ParseException {
  DateTimeZone tz=DateTimeZone.forID("America/Los_Angeles");
  DateTime eventStart=new DateTime(2012,1,4,17,0,tz);
  DateTime eventEnd=new DateTime(2012,1,4,18,0,tz);
  VEvent event=new VEvent(getICal4jDate(eventStart,tz),getICal4jDate(eventEnd,tz),"Test Event");
  DateMidnight intervalStart=new DateMidnight(2012,1,3,tz);
  DateMidnight intervalStop=new DateMidnight(2012,1,5,tz);
  Interval interval=new Interval(intervalStart,intervalStop);
  Set<CalendarDisplayEvent> events=eventDao.getDisplayEvents(event,interval,tz);
  assertEquals(1,events.size());
}
 

Example 12

From project CalendarPortlet, under directory /src/test/java/org/jasig/portlet/calendar/adapter/.

Source file: CalendarEventDaoTest.java

  18 
vote

@Test public void testGetDisplayEventsForLongEvent() throws IOException, URISyntaxException, ParseException {
  DateTimeZone tz=DateTimeZone.forID("America/Los_Angeles");
  DateTime eventStart=new DateTime(2012,1,2,17,0,tz);
  DateTime eventEnd=new DateTime(2012,1,6,2,0,tz);
  VEvent event=new VEvent(getICal4jDate(eventStart,tz),getICal4jDate(eventEnd,tz),"Test Event");
  DateMidnight intervalStart=new DateMidnight(2012,1,3,tz);
  DateMidnight intervalStop=new DateMidnight(2012,1,5,tz);
  Interval interval=new Interval(intervalStart,intervalStop);
  Set<CalendarDisplayEvent> events=eventDao.getDisplayEvents(event,interval,tz);
  assertEquals(3,events.size());
}
 

Example 13

From project Carolina-Digital-Repository, under directory /metadata/src/test/java/edu/unc/lib/dl/util/.

Source file: DateTimeUtilTest.java

  18 
vote

/** 
 * Test method for  {@link edu.unc.lib.dl.util.DateTimeUtil#parseISO8601(java.lang.String)}.
 */
@Test public void testParseISO8601(){
  String test="2008-05-04T14:24:18-05:00";
  DateTime dt=DateTimeUtil.parseISO8601toUTC(test);
  System.err.println("Is this UTC for " + test + "? "+ dt);
  test="200805";
  dt=DateTimeUtil.parseISO8601toUTC(test);
  System.err.println("Is this UTC for " + test + "? "+ dt);
  test="2008-05";
  dt=DateTimeUtil.parseISO8601toUTC(test);
  System.err.println("Is this UTC for " + test + "? "+ dt);
}
 

Example 14

From project cas, under directory /cas-server-support-ldap/src/main/java/org/jasig/cas/adaptors/ldap/.

Source file: LdapPasswordPolicyEnforcer.java

  18 
vote

/** 
 * Converts the numbers in Active Directory date fields for pwdLastSet, accountExpires, lastLogonTimestamp, lastLogon, and badPasswordTime to a common date format.
 * @param pswValue
 */
private DateTime convertDateToActiveDirectoryFormat(final String pswValue){
  final long l=Long.parseLong(pswValue.trim());
  final long totalSecondsSince1601=l / 10000000;
  final long totalSecondsSince1970=totalSecondsSince1601 - TOTAL_SECONDS_FROM_1601_1970;
  final DateTime dt=new DateTime(totalSecondsSince1970 * 1000,DEFAULT_TIME_ZONE);
  logInfo("Recalculated " + this.dateFormat + " "+ this.dateAttribute+ " attribute to "+ dt.toString());
  return dt;
}
 

Example 15

From project cas, under directory /cas-server-support-ldap/src/main/java/org/jasig/cas/adaptors/ldap/.

Source file: LdapPasswordPolicyEnforcer.java

  18 
vote

/** 
 * Determines the expiration date to use based on the settings.
 * @param ldapDateResult
 * @return Constructed the {@link #org DateTime}  object which indicates the expiration date
 */
private DateTime getExpirationDateToUse(final String ldapDateResult){
  DateTime dateValue=null;
  if (isUsingActiveDirectory())   dateValue=convertDateToActiveDirectoryFormat(ldapDateResult);
 else   dateValue=formatDateByPattern(ldapDateResult);
  DateTime expireDate=dateValue.plusDays(this.validDays);
  logDebug("Retrieved date value " + dateValue.toString() + " for date attribute "+ this.dateAttribute+ " and added "+ this.validDays+ " days. The final expiration date is "+ expireDate.toString());
  return expireDate;
}
 

Example 16

From project Cassandra-Client-Tutorial, under directory /src/main/java/com/jeklsoft/cassandraclient/hector/.

Source file: HectorProtocolBufferWithStandardColumnExample.java

  18 
vote

@Override public List<Reading> querySensorReadingsByInterval(UUID sensorId,Interval interval,int maxToReturn){
  SliceQuery<UUID,DateTime,Reading> query=HFactory.createSliceQuery(keyspace,us,ds,rs);
  query.setColumnFamily(columnFamilyName).setKey(sensorId).setRange(new DateTime(interval.getStartMillis()),new DateTime(interval.getEndMillis()),false,maxToReturn);
  QueryResult<ColumnSlice<DateTime,Reading>> result=query.execute();
  List<HColumn<DateTime,Reading>> columns=result.get().getColumns();
  List<Reading> readings=new ArrayList<Reading>();
  for (  HColumn column : columns) {
    DateTime timestamp=(DateTime)column.getName();
    Reading reading=new Reading(sensorId,timestamp,(Reading)column.getValue());
    readings.add(reading);
  }
  return readings;
}
 

Example 17

From project Cassandra-Client-Tutorial, under directory /src/test/java/com/jeklsoft/cassandraclient/astyanax/.

Source file: TestDateTimeSerializer.java

  18 
vote

@Test public void SerializingThenDeserializingDateTimeResultsInSameDateTime(){
  DateTime value=new DateTime(2000,1,1,12,0);
  ByteBuffer buffer=serializer.toByteBuffer(value);
  DateTime deserializedDateTime=serializer.fromByteBuffer(buffer);
  assertEquals(value,deserializedDateTime);
}
 

Example 18

From project 4308Cirrus, under directory /tendril-android-lib/src/main/java/edu/colorado/cs/cirrus/android/.

Source file: TendrilTemplate.java

  17 
vote

private String authorize(boolean refresh,String userName,String password){
  DateTime expiration=new DateTime();
  MultiValueMap<String,String> params=new LinkedMultiValueMap<String,String>();
  params.set("Accept","application/json");
  params.set("Content-Type","application/x-www-form-urlencoded");
  MultiValueMap<String,String> formData=new LinkedMultiValueMap<String,String>();
  formData.add("scope",TendrilUrls.SCOPE);
  if (refresh) {
    formData.add("grant_type","refresh_token");
    formData.add("refresh_token",accessGrant.getRefresh_token());
  }
 else {
    formData.add("client_id",TendrilUrls.APP_KEY);
    formData.add("client_secret",TendrilUrls.APP_SECRET);
    formData.add("grant_type","password");
    formData.add("username",userName);
    formData.add("password",password);
  }
  HttpHeaders requestHeaders=new HttpHeaders();
  requestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
  requestHeaders.set("Accept","application/json");
  HttpEntity<MultiValueMap<String,String>> requestEntity=new HttpEntity<MultiValueMap<String,String>>(formData,requestHeaders);
  ResponseEntity<AccessGrant> response=restTemplate.exchange(TendrilUrls.ACCESS_TOKEN_URL,HttpMethod.POST,requestEntity,AccessGrant.class);
  System.err.println(response);
  accessGrant=response.getBody();
  accessGrant.setExpirationDateTime(expiration.plusSeconds((int)accessGrant.getExpires_in()));
  System.err.println(accessGrant);
  return accessGrant.getAccess_token();
}
 

Example 19

From project 4308Cirrus, under directory /tendril-example/src/main/java/edu/colorado/cs/cirrus/android/.

Source file: PricingScheduleActivity.java

  17 
vote

@Override public void onStart(){
  super.onStart();
  PricingSchedule schedule=null;
  try {
    DateTime startDate=new DateTime().withDate(2011,3,1).withTimeAtStartOfDay();
    DateTime endDate=new DateTime().withDate(2011,3,31).withTimeAtStartOfDay();
    this.showLoadingProgressDialog();
    schedule=tendril.fetchPricingSchedule(startDate,endDate);
    TextView test=(TextView)findViewById(R.id.textView1);
    TextView accountID=(TextView)findViewById(R.id.pricingschedule_accountid);
    TextView effectiveDate=(TextView)findViewById(R.id.pricingschedule_effective_date);
    TextView programName=(TextView)findViewById(R.id.pricingschedule_programname);
    TextView rateKey=(TextView)findViewById(R.id.pricingschedule_rate_key);
    TextView energyPrice=(TextView)findViewById(R.id.pricingschedule_energy_price);
    test.setText(schedule.getEffectivePriceRecords().toString());
    accountID.setText(schedule.getAccountId().toString());
    effectiveDate.setText(schedule.getEffectivePriceRecords().get(0).getEffectiveDate().toString());
    programName.setText(schedule.getEffectivePriceRecords().get(0).getProgramName().toString());
    rateKey.setText(schedule.getEffectivePriceRecords().get(0).getRateKey().toString());
    energyPrice.setText(schedule.getEffectivePriceRecords().get(0).getEnergyPrice().toString());
  }
 catch (  Exception e) {
    e.printStackTrace();
    Toast.makeText(getApplicationContext(),e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
  }
 finally {
    this.dismissProgressDialog();
  }
  System.err.println(schedule);
}
 

Example 20

From project action-core, under directory /src/main/java/com/ning/metrics/action/hdfs/reader/.

Source file: HdfsEntry.java

  17 
vote

@JsonCreator @SuppressWarnings("unused") public HdfsEntry(@JsonProperty(JSON_ENTRY_PATH) String path,@JsonProperty(JSON_ENTRY_MTIME) long mtime,@JsonProperty(JSON_ENTRY_SIZE) long sizeInBytes,@JsonProperty(JSON_ENTRY_REPLICATION) short replication,@JsonProperty(JSON_ENTRY_IS_DIR) boolean isDirectory){
  this.fs=null;
  this.path=new Path(path);
  this.modificationDate=new DateTime(mtime);
  this.blockSize=-1;
  this.size=sizeInBytes;
  this.replication=replication;
  this.replicatedSize=sizeInBytes * replication;
  this.directory=isDirectory;
  this.raw=true;
  this.rowFileContentsIteratorFactory=null;
}
 

Example 21

From project action-core, under directory /src/main/java/com/ning/metrics/action/hdfs/reader/.

Source file: HdfsEntry.java

  17 
vote

public HdfsEntry(FileSystem fs,FileStatus status,boolean raw,RowFileContentsIteratorFactory rowFileContentsIteratorFactory) throws IOException {
  this.fs=fs;
  this.path=status.getPath();
  this.modificationDate=new DateTime(status.getModificationTime());
  this.blockSize=status.getBlockSize();
  this.size=status.getLen();
  this.replication=status.getReplication();
  this.replicatedSize=status.getReplication() * status.getLen();
  this.directory=status.isDir();
  this.raw=raw;
  this.rowFileContentsIteratorFactory=rowFileContentsIteratorFactory;
}
 

Example 22

From project apollo, under directory /injector/src/main/java/com/bskyb/cg/environments/message/.

Source file: AuditdMessageFormat.java

  17 
vote

@Override public Message parse(byte[] inMessage) throws ParseException {
  Message message=new LogMessage();
  String textMessage=new String(inMessage);
  StringTokenizer st=new StringTokenizer(textMessage,delimiter);
  String msgType=(String)st.nextElement();
  String timeStamp=(String)st.nextElement();
  DateTime longDate=null;
  try {
    longDate=parseDate(timeStamp);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (longDate == null) {
    return message;
  }
  String year=new Integer(longDate.getYear()).toString();
  String month=String.format("%02d",new Integer(longDate.getMonthOfYear()));
  String day=String.format("%02d",new Integer(longDate.getDayOfMonth()));
  String hostName=(String)st.nextElement();
  long epochTime=longDate.getMillis();
  UUID uuid=TimeUUIDUtils.getTimeUUID(epochTime);
  String filename=year + "-" + month+ "-"+ day+ "_"+ hostName+ "_"+ msgType+ "_"+ uuid.toString()+ "_"+ new Long(epochTime).toString();
  String messageText=(String)st.nextElement();
  message.setKey(filename);
  message.setMessage(messageText.getBytes());
  return message;
}
 

Example 23

From project astyanax, under directory /src/main/java/com/netflix/astyanax/connectionpool/impl/.

Source file: NodeDiscoveryImpl.java

  17 
vote

private void update(){
  try {
    connectionPool.setHosts(tokenRangeSupplier.get());
    refreshCounter.incrementAndGet();
    lastUpdateTime.set(new DateTime());
  }
 catch (  Exception e) {
    errorCounter.incrementAndGet();
    lastException.set(e);
  }
}
 

Example 24

From project Carolina-Digital-Repository, under directory /metadata/src/main/java/edu/unc/lib/dl/util/.

Source file: DateTimeUtil.java

  17 
vote

/** 
 * Parse a date in any ISO 8601 format. Default TZ is based on Locale.
 * @param isoDate ISO8601 date/time string with or without TZ offset
 * @return a Joda DateTime object in UTC (call toString() to print)
 */
public static DateTime parseISO8601toUTC(String isoDate){
  DateTime result=null;
  DateTimeFormatter fmt=ISODateTimeFormat.dateTimeParser().withOffsetParsed();
  DateTime isoDT=fmt.parseDateTime(isoDate);
  if (isoDT.year().get() > 9999) {
    try {
      fmt=DateTimeFormat.forPattern("yyyyMMdd");
      fmt=fmt.withZone(DateTimeZone.forID("America/New_York"));
      isoDT=fmt.parseDateTime(isoDate);
    }
 catch (    IllegalArgumentException e) {
      try {
        fmt=DateTimeFormat.forPattern("yyyyMM");
        fmt=fmt.withZone(DateTimeZone.forID("America/New_York"));
        isoDT=fmt.parseDateTime(isoDate);
      }
 catch (      IllegalArgumentException e1) {
        try {
          fmt=DateTimeFormat.forPattern("yyyy");
          fmt=fmt.withZone(DateTimeZone.forID("America/New_York"));
          isoDT=fmt.parseDateTime(isoDate);
        }
 catch (        IllegalArgumentException ignored) {
        }
      }
    }
  }
  result=isoDT.withZoneRetainFields(DateTimeZone.forID("Etc/UTC"));
  return result;
}
 

Example 25

From project airlift, under directory /event/src/main/java/io/airlift/event/client/.

Source file: EventJsonSerializerV2.java

  16 
vote

@Override public void serialize(T event,JsonGenerator jsonGenerator,SerializerProvider provider) throws IOException {
  jsonGenerator.writeStartObject();
  jsonGenerator.writeStringField("type",eventTypeMetadata.getTypeName());
  if (eventTypeMetadata.getUuidField() != null) {
    eventTypeMetadata.getUuidField().writeField(jsonGenerator,event);
  }
 else {
    jsonGenerator.writeStringField("uuid",UUID.randomUUID().toString());
  }
  if (eventTypeMetadata.getHostField() != null) {
    eventTypeMetadata.getHostField().writeField(jsonGenerator,event);
  }
 else {
    jsonGenerator.writeStringField("host",hostName);
  }
  if (eventTypeMetadata.getTimestampField() != null) {
    eventTypeMetadata.getTimestampField().writeField(jsonGenerator,event);
  }
 else {
    jsonGenerator.writeFieldName("timestamp");
    EventDataType.DATETIME.writeFieldValue(jsonGenerator,new DateTime());
  }
  jsonGenerator.writeObjectFieldStart("data");
  for (  EventFieldMetadata field : eventTypeMetadata.getFields()) {
    field.writeField(jsonGenerator,event);
  }
  jsonGenerator.writeEndObject();
  jsonGenerator.writeEndObject();
  jsonGenerator.flush();
}
 

Example 26

From project atlas, under directory /src/main/java/com/ning/atlas/components/databases/.

Source file: OracleLoaderInstaller.java

  16 
vote

@SuppressWarnings("unchecked") @Override public String perform(Host host,Uri<? extends Component> uri,Deployment d) throws Exception {
  String fragment=uri.getFragment();
  final ST sql_url_t=new ST(sqlUrlTemplate);
  final Splitter equal_splitter=Splitter.on('=');
  for (  String pair : Splitter.on(';').split(fragment)) {
    Iterator<String> itty=equal_splitter.split(pair).iterator();
    sql_url_t.add(itty.next(),itty.next());
  }
  String sql_url=sql_url_t.toString();
  if (d.getSpace().get(host.getId(),sql_url).isKnown()) {
    return "already installed";
  }
  SSHCredentials creds=SSHCredentials.lookup(d.getSpace(),credentialName).otherwise(SSHCredentials.defaultCredentials(d.getSpace())).otherwise(new IllegalStateException("unable to find ssh credentials"));
  String oracle_shell_id=d.getScratch().get("oracle-shell").otherwise(new IllegalStateException("no oracle-shell available"));
  String attrs=d.getSpace().get(host.getId(),"extra-atlas-attributes").getValue();
  Map<String,String> attr=new ObjectMapper().readValue(attrs,Map.class);
  Server shell=d.getSpace().get(Identity.valueOf(oracle_shell_id),Server.class,Missing.RequireAll).getValue();
  Server server=d.getSpace().get(host.getId(),Server.class,Missing.RequireAll).getValue();
  if (d.getSpace().get(host.getId(),sql_url).isKnown()) {
    return "Nothing to be done for " + sql_url;
  }
  SSH ssh=new SSH(creds,shell.getExternalAddress());
  try {
    String s3_fetch=String.format("s3cmd get %s do_it.sql",sql_url);
    log.info(s3_fetch);
    ssh.exec(s3_fetch);
    String cmd=format("sqlplus %s/%[email protected]\"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SID=%s)))\" @do_it.sql",attr.get("username"),attr.get("password"),server.getInternalAddress(),attr.get("port"),attr.get("name"));
    log.info("about to load sql via [ " + cmd + " ]");
    String out=ssh.exec(cmd);
    d.getSpace().store(host.getId(),sql_url,new DateTime().toString());
    return out;
  }
  finally {
    ssh.close();
  }
}
 

Example 27

From project airlift, under directory /event/src/main/java/io/airlift/event/client/.

Source file: EventFieldMetadata.java

  15 
vote

public void writeTimestampV1(JsonGenerator jsonGenerator,Object event) throws IOException {
  Object value=getValue(event);
  if (value != null) {
    EventDataType.validateFieldValueType(value,DateTime.class);
    jsonGenerator.writeNumberField("timestamp",((DateTime)value).getMillis());
  }
}