List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:org.tanrabad.survey.utils.time.ThaiDatePrinter.java
License:Apache License
public static String print(DateTime dateTime) { return String.format(Locale.US, "%d %s %04d", dateTime.getDayOfMonth(), ThaiMonthMapper.getMonth(dateTime.getMonthOfYear()), dateTime.getYear() + 543); }
From source file:org.terasoluna.tourreservation.app.searchtour.SearchTourController.java
License:Apache License
/** * pre-initialization of form backed bean * @return// www . j a v a 2 s.c o m */ @ModelAttribute public SearchTourForm setUpSearchTourForm() { SearchTourForm searchTourForm = new SearchTourForm(); DateTime dateTime = dateFactory.newDateTime(); DateTime nextWeekDate = dateTime.plusWeeks(1); searchTourForm.setDepYear(nextWeekDate.getYear()); searchTourForm.setDepMonth(nextWeekDate.getMonthOfYear()); searchTourForm.setDepDay(nextWeekDate.getDayOfMonth()); log.debug("populate form {}", searchTourForm); return searchTourForm; }
From source file:org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl.java
License:Open Source License
@Override public List<Result<ExecutionTimeOfAPIValues>> getExecutionTimeByAPI(String apiName, String version, String tenantDomain, String fromDate, String toDate, String drillDown, String mediationType) throws APIMgtUsageQueryServiceClientException { List<Result<ExecutionTimeOfAPIValues>> result = new ArrayList<Result<ExecutionTimeOfAPIValues>>(); try {/*from w w w. j a v a2s .c o m*/ StringBuilder query = new StringBuilder( "from " + APIUsageStatisticsClientConstants.API_EXECUTION_TIME_AGG + " on(" + APIUsageStatisticsClientConstants.API_NAME + "=='" + apiName + "'"); if (version != null) { query.append(" AND " + APIUsageStatisticsClientConstants.API_VERSION + "=='" + version + "'"); } if (tenantDomain != null) { query.append(" AND " + APIUsageStatisticsClientConstants.API_CREATOR_TENANT_DOMAIN + "=='" + tenantDomain + "'"); } if (fromDate != null && toDate != null) { String granularity = APIUsageStatisticsClientConstants.SECONDS_GRANULARITY; Map<String, Integer> durationBreakdown = this.getDurationBreakdown(fromDate, toDate); LocalDateTime currentDate = LocalDateTime.now(DateTimeZone.UTC); DateTimeFormatter formatter = DateTimeFormat .forPattern(APIUsageStatisticsClientConstants.TIMESTAMP_PATTERN); LocalDateTime fromLocalDateTime = LocalDateTime.parse(fromDate, formatter);//GMT time if (fromLocalDateTime.isBefore(currentDate.minusYears(1))) { granularity = APIUsageStatisticsClientConstants.MONTHS_GRANULARITY; } else if (durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_MONTHS) > 0 || durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_WEEKS) > 0) { granularity = APIUsageStatisticsClientConstants.DAYS_GRANULARITY; } else if (durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_DAYS) > 0) { granularity = APIUsageStatisticsClientConstants.HOURS_GRANULARITY; } else if (durationBreakdown.get(APIUsageStatisticsClientConstants.DURATION_HOURS) > 0) { granularity = APIUsageStatisticsClientConstants.MINUTES_GRANULARITY; } query.append(") within " + getTimestamp(fromDate) + "L, " + getTimestamp(toDate) + "L per '" + granularity + "'"); } else { query.append(") within " + 0 + "L, " + new Date().getTime() + "L per 'months'"); } query.append(" select " + APIUsageStatisticsClientConstants.API_NAME + ", " + APIUsageStatisticsClientConstants.API_CONTEXT + ", " + APIUsageStatisticsClientConstants.API_CREATOR + ", " + APIUsageStatisticsClientConstants.API_VERSION + ", " + APIUsageStatisticsClientConstants.TIME_STAMP + ", " + APIUsageStatisticsClientConstants.RESPONSE_TIME + ", " + APIUsageStatisticsClientConstants.SECURITY_LATENCY + ", " + APIUsageStatisticsClientConstants.THROTTLING_LATENCY + ", " + APIUsageStatisticsClientConstants.REQUEST_MEDIATION_LATENCY + ", " + APIUsageStatisticsClientConstants.RESPONSE_MEDIATION_LATENCY + ", " + APIUsageStatisticsClientConstants.BACKEND_LATENCY + ", " + APIUsageStatisticsClientConstants.OTHER_LATENCY + ";"); JSONObject jsonObj = APIUtil.executeQueryOnStreamProcessor( APIUsageStatisticsClientConstants.APIM_ACCESS_SUMMARY_SIDDHI_APP, query.toString()); long timeStamp; if (jsonObj != null) { JSONArray jArray = (JSONArray) jsonObj.get(APIUsageStatisticsClientConstants.RECORDS_DELIMITER); for (Object record : jArray) { JSONArray recordArray = (JSONArray) record; if (recordArray.size() == 12) { Result<ExecutionTimeOfAPIValues> result1 = new Result<ExecutionTimeOfAPIValues>(); ExecutionTimeOfAPIValues executionTimeOfAPIValues = new ExecutionTimeOfAPIValues(); executionTimeOfAPIValues.setApi((String) recordArray.get(0)); executionTimeOfAPIValues.setContext((String) recordArray.get(1)); executionTimeOfAPIValues.setApiPublisher((String) recordArray.get(2)); executionTimeOfAPIValues.setVersion((String) recordArray.get(3)); timeStamp = (Long) recordArray.get(4); DateTime time = new DateTime(timeStamp).withZone(DateTimeZone.UTC); executionTimeOfAPIValues.setYear(time.getYear()); executionTimeOfAPIValues.setMonth(time.getMonthOfYear()); executionTimeOfAPIValues.setDay(time.getDayOfMonth()); executionTimeOfAPIValues.setHour(time.getHourOfDay()); executionTimeOfAPIValues.setMinutes(time.getMinuteOfHour()); executionTimeOfAPIValues.setSeconds(time.getSecondOfMinute()); executionTimeOfAPIValues.setApiResponseTime((Long) recordArray.get(5)); executionTimeOfAPIValues.setSecurityLatency((Long) recordArray.get(6)); executionTimeOfAPIValues.setThrottlingLatency((Long) recordArray.get(7)); executionTimeOfAPIValues.setRequestMediationLatency((Long) recordArray.get(8)); executionTimeOfAPIValues.setResponseMediationLatency((Long) recordArray.get(9)); executionTimeOfAPIValues.setBackendLatency((Long) recordArray.get(10)); executionTimeOfAPIValues.setOtherLatency((Long) recordArray.get(11)); result1.setValues(executionTimeOfAPIValues); result1.setTableName(APIUsageStatisticsClientConstants.API_EXECUTION_TIME_AGG); result1.setTimestamp(RestClientUtil.longToDate(new Date().getTime())); result.add(result1); } } } if (!result.isEmpty() && fromDate != null && toDate != null) { insertZeroElementsAndSort(result, drillDown, getDateToLong(fromDate), getDateToLong(toDate)); } } catch (APIManagementException e) { handleException("Error occurred while querying from Stream Processor ", e); } catch (ParseException e) { handleException("Couldn't parse the date", e); } return result; }
From source file:org.wso2.strategy.carbon.CarbonKernelHandler.java
License:Open Source License
private String buildCarbonDockerImage(String tenant, Path artifact, String version) throws CarbonKernelHandlerException { String kernelArtifact = artifact.getFileName().toString(); List<String> dockerFileContent = setDockerFileContent(kernelArtifact); Path parentDirectory = artifact.getParent(); File dockerFile;/*from w ww . j a va2 s .c om*/ if (parentDirectory != null) { String parentDirectoryPath = parentDirectory.toString(); dockerFile = new File(parentDirectoryPath + File.separator + "Dockerfile"); } else { dockerFile = new File("Dockerfile"); } CarbonKernelHandlerHelper.writeToFile(dockerFile.getAbsolutePath(), dockerFileContent); DateTime dateTime = new DateTime(); String now = dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth() + "-" + dateTime.getMillisOfDay(); version += ("-" + now); return imageBuilder.buildImage(tenant, CarbonKernelHandlerConstants.ARTIFACT_NAME, version, Paths.get(dockerFile.getAbsolutePath())); }
From source file:org.wso2.strategy.poc.webartifact.WebArtifactHandler.java
License:Open Source License
public boolean deploy(String tenant, String appName, Path artifactPath, String version, int replicas) throws WebArtifactHandlerException { String componentName = WebArtifactHandlerHelper.generateKubernetesComponentIdentifier(tenant, appName); String dockerImageName;/*from w w w . j av a 2 s. c o m*/ try { if (imageBuilder.getExistingImages(tenant, appName, version).size() == 0) { // append build date and time to major version DateTime dateTime = new DateTime(); String now = dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth() + "-" + dateTime.getMillisOfDay(); version += ("-" + now); dockerImageName = imageBuilder.buildImage(tenant, appName, version, artifactPath); Thread.sleep(IMAGE_BUILD_DELAY_IN_MILLISECONDS); replicationControllerHandler.createReplicationController(componentName, componentName, dockerImageName, replicas); serviceHandler.createService(componentName, componentName); return true; } else { return false; } } catch (Exception exception) { String message = String.format("Failed to deploy web artifact[web-artifact]: %s", artifactPath.toString()); LOG.error(message, exception); throw new WebArtifactHandlerException(message, exception); } }
From source file:org.wso2.strategy.poc.webartifact.WebArtifactHandler.java
License:Open Source License
public boolean rollUpdate(String tenant, String appName, String version, Path artifactPath) throws WebArtifactHandlerException { String componentName = WebArtifactHandlerHelper.generateKubernetesComponentIdentifier(tenant, appName); if ((imageBuilder.getExistingImages(tenant, appName, version).size() > 0)) { DateTime dateTime = new DateTime(); String now = dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth() + "-" + dateTime.getMillisOfDay(); version += ("-" + now); String dockerImageName = imageBuilder.buildImage(tenant, appName, version, artifactPath); replicationControllerHandler.updateImage(componentName, dockerImageName); podHandler.deleteReplicaPods(//from w ww .ja v a 2s . c om replicationControllerHandler.getReplicationController( WebArtifactHandlerHelper.generateKubernetesComponentIdentifier(tenant, appName)), tenant, appName); return true; } else { return false; } }
From source file:org.xmlcml.euclid.JodaDate.java
License:Apache License
@SuppressWarnings("deprecation") public static Date parseJodaDate(DateTime jodaDate) { int year = jodaDate.getYear(); int month = jodaDate.getMonthOfYear(); int day = jodaDate.getDayOfMonth(); int hour = jodaDate.getHourOfDay(); int min = jodaDate.getMinuteOfDay(); int sec = jodaDate.getSecondOfMinute(); // arghh//from w w w. j a va2s .c o m Date date = new Date(year - 1900, month, day, hour, min, sec); return date; }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailFourTimeTrackerState.java
License:Open Source License
private int getSizeMonth(DateTime dateTime) { Calendar cal = new GregorianCalendar(dateTime.getYear(), dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth()); // Get the number of days in that month int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); return BigDecimal.valueOf(pixelPerDay() * days).intValue(); }
From source file:org.zkoss.ganttz.timetracker.zoom.DetailSixTimeTrackerState.java
License:Open Source License
@Override protected IDetailItemCreator getDetailItemCreatorSecondLevel() { return new IDetailItemCreator() { @Override/* w w w . ja v a2 s . c o m*/ public DetailItem create(DateTime dateTime) { return new DetailItem(SECOND_LEVEL_SIZE, dateTime.getDayOfMonth() + "", dateTime, dateTime.plusDays(1)); } }; }
From source file:proxi.model.ProxiCSVWriter.java
License:Open Source License
private static String[] dateTimeCutter(DateTime dt) { String[] dtParts = new String[6]; String year = "" + dt.getYear(); String month = fixWith2Chars(dt.getMonthOfYear()); String day = fixWith2Chars(dt.getDayOfMonth()); String hour = fixWith2Chars(dt.getHourOfDay()); String minute = fixWith2Chars(dt.getMinuteOfHour()); String second = fixWith2Chars(dt.getSecondOfMinute()); dtParts[0] = year;/*from w w w . j ava 2s. c o m*/ dtParts[1] = month; dtParts[2] = day; dtParts[3] = hour; dtParts[4] = minute; dtParts[5] = second; return dtParts; }