List of usage examples for org.joda.time DateTime toString
public String toString(String pattern)
From source file:aplicacion.control.util.Fechas.java
public static String getFechaConMesYHora(Timestamp timestamp) { DateTime dateTime = new DateTime(timestamp.getTime()); String fecha = dateTime.getDayOfMonth() + " de " + getMonthName(dateTime.getMonthOfYear()) + " " + dateTime.getYear() + " a las " + dateTime.toString("HH:mm:ss"); return fecha; }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaCorta(Timestamp timestamp) { DateTime dateTime = new DateTime(timestamp.getTime()); return dateTime.toString("dd/MM/yyyy"); }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaCorta(DateTime dateTime) { return dateTime.toString("dd/MM/yyyy"); }
From source file:au.id.hazelwood.xmltvguidebuilder.utils.DateTimeUtils.java
License:Apache License
public static String toISODateTime(DateTime dateTime) { return dateTime.toString(ISODateTimeFormat.dateHourMinute()); }
From source file:AuditGenerator.SeedData.java
private static void createAudit(String date, String childId, String parentId, int statusIndex, int siteId, int referringUrlId) throws SQLException, InterruptedException { String sql;/* www . jav a 2 s .co m*/ String currentSeverityId = "1"; DateTime currentTime = DateTime.now(); int randomSecond = randomGenerator.nextInt(100000); currentTime = currentTime.minusSeconds(randomSecond); DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); String due = currentTime.toString(fmt); String thisSiteId = "" + siteId; if (referringUrlId == -1) { if (statusIndex == 0 || statusIndex == 1) { System.out.println("statusIndex " + statusIndex); sql = "INSERT into " + dbName + ".audits (created_at, updated_at, status, site_id, due_at, published_at,audit_type_id) VALUES ('" + date + "', '" + date + "', 'published', " + thisSiteId + ",'" + due + "', '" + date + "',1)"; } else { sql = "INSERT into " + dbName + ".audits (created_at, updated_at, status, site_id,referral_url_id, due_at,audit_type_id) VALUES ('" + date + "', '" + date + "', 'unaudited', " + thisSiteId + ",'" + due + "',1)"; } } else { if (statusIndex == 0 || statusIndex == 1) { System.out.println("statusIndex " + statusIndex); sql = "INSERT into " + dbName + ".audits (created_at, updated_at, status, site_id, referral_url_id, due_at, published_at,audit_type_id) VALUES ('" + date + "', '" + date + "', 'published', " + thisSiteId + "," + referringUrlId + ",'" + due + "', '" + date + "',1)"; } else { sql = "INSERT into " + dbName + ".audits (created_at, updated_at, status, site_id,referral_url_id, due_at,audit_type_id) VALUES ('" + date + "', '" + date + "', 'unaudited', " + thisSiteId + "," + referringUrlId + ",'" + due + "',1)"; } } //Grab audit ID from insert int auditId = sqlHandler.getSQLResponse(sql); String typePMMSQL = "INSERT INTO " + dbName + ".audit_audit_types (audit_id, audit_type_id, created_at, updated_at) VALUES (" + auditId + ", 1, '" + date + "','" + date + "')"; sqlHandler.executeStatement(typePMMSQL); ArrayList addContent = new ArrayList<String>(); addContent.add(4); Iterator it = addContent.iterator(); while (it.hasNext()) { int nextContent = (int) it.next(); String sql3 = "INSERT INTO " + dbName + ".audit_content_types (audit_id, content_type_id, created_at, updated_at) VALUES (" + auditId + ", " + nextContent + ", '" + date + "', '" + date + "')"; System.out.println(sql3); sqlHandler.executeStatement(sql3); //severities are related to content type String sql4 = "INSERT INTO " + dbName + ".audit_client_content_type_severities (audit_id, severity_id, content_type_id, client_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + "," + nextContent + ", " + childId + ", '" + date + "', '" + date + "')"; System.out.println(sql4); sqlHandler.executeStatement(sql4); if (parentId != null && statusIndex == 1) { String parentContentSQL = "INSERT INTO " + dbName + ".audit_client_content_type_severities (audit_id, severity_id, content_type_id, client_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + "," + nextContent + ", " + parentId + ", '" + date + "', '" + date + "')"; sqlHandler.executeStatement(parentContentSQL); } } if (statusIndex == 1) { String thisResolution = "cleared"; String sql5; if ("Under Review".equals(thisResolution)) { sql5 = "INSERT INTO " + dbName + ".audit_client_merchant_resolutions " + "(audit_id, severity_id, status, author_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + ", '" + thisResolution + "', " + childId + ", '" + date + "', '" + date + "')"; } else { sql5 = "INSERT INTO " + dbName + ".audit_client_merchant_resolutions " + "(audit_id, severity_id, status, author_organization_id, recipient_organization_id, published_at, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + ", '" + thisResolution + "', " + childId + ", " + parentId + ", '" + date + "', '" + date + "', '" + date + "')"; } System.out.println("merchant res sql " + sql5); sqlHandler.executeStatement(sql5); } // create one or more notes Random r = new Random(); int noteCount = r.nextInt(6 - 1) + 1; for (int i = 0; i < noteCount; i++) { generateNotes(auditId, i); } generateAuditChange(auditId); }
From source file:AuditGenerator.SeedData.java
private static void generateAudits() throws SQLException, InterruptedException { //generate 10 audits for Acq1 DateTime thisDateTime = new DateTime(); DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); String sqlDate = thisDateTime.toString(fmt); String orgId = "227"; String parentId = "229"; Integer siteId = 201;/*from w w w.j av a 2 s . c o m*/ for (int i = 1; i < 50; i++) { siteId++; createAudit(sqlDate, orgId, parentId, 1, siteId, i + 300); } String a2Id = "228"; //generate 10 audits for acq 2 for (int i = 1; i < 50; i++) { siteId++; createAudit(sqlDate, a2Id, parentId, 1, siteId, -1); } //generate 10 audits for solo org String soloId = "230"; for (int i = 1; i < 50; i++) { siteId++; createAudit(sqlDate, soloId, null, 1, siteId, -1); } //generate 19 audits for vcm 1 String vcmId = "231"; for (int i = 1; i < 60; i++) { createMultiAudit(sqlDate, vcmId, "227", "228", 1, i); } //generate 10 non-published audits for vcm1 String vcmId1 = "231"; for (int i = 1; i < 11; i++) { createAudit(sqlDate, vcmId1, "0", 0, i, -1); } //generate violations for audit 31 (site 1) for vcms 2-51 int baseVCM = 231; for (int i = 0; i < 50; i++) { int vcm = baseVCM + i; generateContent(vcm + ""); } }
From source file:AuditGenerator.SeedData.java
private static void createMultiAudit(String date, String childId, String parentId1, String parentId2, int statusIndex, int siteId) { String sql;//from www .j av a 2s .c o m String currentSeverityId = "1"; DateTime currentTime = DateTime.now(); int randomSecond = randomGenerator.nextInt(100000); currentTime = currentTime.minusSeconds(randomSecond); DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); String due = currentTime.toString(fmt); String thisSiteId = "" + siteId; if (statusIndex == 0 || statusIndex == 1) { System.out.println("statusIndex " + statusIndex); sql = "INSERT into " + dbName + ".audits (created_at, updated_at, status, site_id, due_at, published_at) VALUES ('" + date + "', '" + date + "', 'published', " + thisSiteId + ", '" + due + "', '" + date + "')"; } else { sql = "INSERT into " + dbName + ".audits (created_at, updated_at, status, site_id, due_at) VALUES ('" + date + "', '" + date + "', 'unaudited', " + thisSiteId + ", '" + due + "')"; } //Grab audit ID from insert int auditId = sqlHandler.getSQLResponse(sql); String typePMMSQL = "INSERT INTO " + dbName + ".audit_audit_types (audit_id, audit_type_id, created_at, updated_at) VALUES (" + auditId + ", 1, '" + date + "','" + date + "')"; sqlHandler.executeStatement(typePMMSQL); ArrayList addContent = new ArrayList<String>(); addContent.add(4); Iterator it = addContent.iterator(); while (it.hasNext()) { int nextContent = (int) it.next(); String sql3 = "INSERT INTO " + dbName + ".audit_content_types (audit_id, content_type_id, created_at, updated_at) VALUES (" + auditId + ", " + nextContent + ", '" + date + "', '" + date + "')"; System.out.println(sql3); sqlHandler.executeStatement(sql3); //severities are related to content type String sql4 = "INSERT INTO " + dbName + ".audit_client_content_type_severities (audit_id, severity_id, content_type_id, client_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + "," + nextContent + ", " + childId + ", '" + date + "', '" + date + "')"; System.out.println(sql4); sqlHandler.executeStatement(sql4); if (parentId1 != null && statusIndex == 1) { String parentContentSQL = "INSERT INTO " + dbName + ".audit_client_content_type_severities (audit_id, severity_id, content_type_id, client_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + "," + nextContent + ", " + parentId1 + ", '" + date + "', '" + date + "')"; String parentContent2SQL = "INSERT INTO " + dbName + ".audit_client_content_type_severities (audit_id, severity_id, content_type_id, client_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + "," + nextContent + ", " + parentId2 + ", '" + date + "', '" + date + "')"; sqlHandler.executeStatement(parentContentSQL); sqlHandler.executeStatement(parentContent2SQL); } } if (statusIndex == 1) { String thisResolution = "cleared"; String sql5, sql6; if ("Under Review".equals(thisResolution)) { sql5 = "INSERT INTO " + dbName + ".audit_client_merchant_resolutions " + "(audit_id, severity_id, status, author_organization_id, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + ", '" + thisResolution + "', " + childId + ", '" + date + "', '" + date + "')"; sql6 = ""; } else { sql5 = "INSERT INTO " + dbName + ".audit_client_merchant_resolutions " + "(audit_id, severity_id, status, author_organization_id, recipient_organization_id, published_at, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + ", '" + thisResolution + "', " + childId + ", " + parentId1 + ", '" + date + "', '" + date + "', '" + date + "')"; sql6 = "INSERT INTO " + dbName + ".audit_client_merchant_resolutions " + "(audit_id, severity_id, status, author_organization_id, recipient_organization_id, published_at, created_at, updated_at)" + "VALUES (" + auditId + ", " + currentSeverityId + ", '" + thisResolution + "', " + childId + ", " + parentId2 + ", '" + date + "', '" + date + "', '" + date + "')"; } System.out.println("merchant res sql " + sql5); sqlHandler.executeStatement(sql5); sqlHandler.executeStatement(sql6); } }
From source file:azkaban.app.Scheduler.java
License:Apache License
private Props createScheduleProps() { Props props = new Props(); for (ScheduledJob job : _scheduled.values()) { String name = job.getId(); ReadablePeriod period = job.getPeriod(); String periodStr = createPeriodString(period); DateTime time = job.getScheduledExecution(); String nextScheduledStr = time.toString(FILE_DATEFORMAT); String dependency = String.valueOf(job.isDependencyIgnored()); props.put(name, nextScheduledStr + " " + periodStr + " " + dependency); }//from www. j ava2s .c o m return props; }
From source file:bamons.process.batch.task.BatchScheduledTasks.java
License:Open Source License
public void sampleJob() throws Exception { try {//from www. j av a 2 s . c o m DateTime dt = new DateTime(); dt = dt.minusDays(1); String targetDate = dt.toString(DateTimeFormat.forPattern("yyyy-MM-dd")); JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis()) .addString("targetDate", targetDate).toJobParameters(); JobExecution execution = jobLauncher.run(sampleJob, jobParameters); } catch (Exception e) { e.printStackTrace(); } }
From source file:be.dnsbelgium.rdap.jackson.DateTimeSerializer.java
License:Apache License
@Override public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (value == null) { jgen.writeNull();//from w w w . ja v a2s.c om } else { jgen.writeString(value.toString(ISODateTimeFormat.dateTimeNoMillis())); } }