List of usage examples for java.util GregorianCalendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:org.geosdi.geoplatform.services.GPPublisherBasicServiceImpl.java
private void addShpCleanerJob(String userWorkspace, String layerName, String filePath) { if (GPSharedUtils.isEmpty(userWorkspace) || GPSharedUtils.isEmpty(layerName)) { throw new IllegalArgumentException( "The workspace: " + userWorkspace + " or the layerName: " + layerName + " are null"); }/*from w w w . j a v a2 s .c om*/ TriggerKey triggerKey = new TriggerKey(userWorkspace + ":" + layerName, PublisherScheduler.PUBLISHER_GROUP); GregorianCalendar calendar = new GregorianCalendar(); calendar.add(Calendar.MINUTE, 30); Trigger trigger = TriggerBuilder.newTrigger().forJob(this.scheduler.getCleanerJobShpDetail()) .withIdentity(triggerKey).withDescription("Runs after 30 minutes").startAt(calendar.getTime()) .withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule() .withMisfireHandlingInstructionFireAndProceed()) .build(); trigger.getJobDataMap().put(PublishUtility.USER_WORKSPACE, userWorkspace); trigger.getJobDataMap().put(PublisherShpCleanerJob.LAYER_NAME, layerName); trigger.getJobDataMap().put(PublishUtility.FILE_PATH, filePath); trigger.getJobDataMap().put(PublishUtility.PUBLISHER_SERVICE, this); this.scheduleTrigger(triggerKey, trigger); }
From source file:org.vanbest.xmltv.RTL.java
@Override public List<Programme> getProgrammes(List<Channel> channels, int day) throws Exception { List<Programme> result = new LinkedList<Programme>(); Map<String, Channel> channelMap = new HashMap<String, Channel>(); for (Channel c : channels) { if (c.enabled && c.source.equals(getName())) channelMap.put(c.id, c);//from w w w . ja v a 2 s . c o m } GregorianCalendar now = new GregorianCalendar(); GregorianCalendar date = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); date.add(Calendar.DAY_OF_MONTH, day); // Note: this fetches all programmes up to and including the // requested date! URL url = programmeUrl(0, day); JSONObject json = fetchJSON(url); // First parse the library JSONArray library = json.getJSONArray("library"); parseLibrary(library); // Then the schedules JSONArray schedules = json.getJSONArray("schedule"); for (int i = 0; i < schedules.size(); i++) { JSONObject schedule = schedules.getJSONObject(i); // Skip programme if station not in channel list String station = schedule.getString("station"); if (!channelMap.containsKey(station)) { if (!config.quiet) logger.trace("Skipping programmes for channel " + station); continue; } Programme prog = createProgramme(schedule, channelMap); if (!prog.startTime.before(date.getTime())) result.add(prog); } return result; }
From source file:com.joey.software.MoorFLSI.RepeatImageTextReader.java
public void loadTextData(File file) { try {/* w ww. ja va 2 s .c o m*/ RandomAccessFile in = new RandomAccessFile(file, "r"); // Skip header in.readLine(); in.readLine(); in.readLine(); // Skip Subject Information in.readLine(); in.readLine(); in.readLine(); in.readLine(); in.readLine(); in.readLine(); String startTimeInput = in.readLine(); String commentsInput = in.readLine(); String data = in.readLine(); while (!data.startsWith("2) System Configuration")) { commentsInput += data; data = in.readLine(); } // System configuration // in.readLine(); in.readLine(); String timeCounstantInput = in.readLine(); String cameraGainInput = in.readLine(); String exposureTimeInput = in.readLine(); in.readLine(); in.readLine(); in.readLine(); String resolutionInput = in.readLine(); // Time Data in.readLine(); String timeDataInput = in.readLine(); String totalImagesInput = in.readLine(); in.readLine(); in.readLine(); // in.readLine(); // System.out.println(in.readLine()); // in.readLine(); // Parse important Size high = (new Scanner(resolutionInput.split(":")[1])).nextInt(); wide = (new Scanner(resolutionInput.split(",")[1])).nextInt(); int tot = 1; try { tot = (new Scanner(totalImagesInput.split(":")[1])).nextInt(); } catch (Exception e) { } System.out.println(wide + "," + high); // Parse timeInformation SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss (dd/MM/yy)"); Date startTime = null; try { startTime = format.parse(startTimeInput.split(": ")[1]); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } String[] frameTimeData = timeDataInput.split("information:")[1].split(","); Date[] timeInfo = new Date[tot]; for (int i = 0; i < frameTimeData.length - 1; i++) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(startTime); String dat = (frameTimeData[i]); String[] timeVals = dat.split(":"); int hour = Integer.parseInt(StringOperations.removeNonNumber(timeVals[0])); int min = Integer.parseInt(StringOperations.removeNonNumber(timeVals[1])); int sec = Integer.parseInt(StringOperations.removeNonNumber(timeVals[2])); int msec = Integer.parseInt(StringOperations.removeNonNumber(timeVals[3])); cal.add(Calendar.HOUR_OF_DAY, hour); cal.add(Calendar.MINUTE, min); cal.add(Calendar.SECOND, sec); cal.add(Calendar.MILLISECOND, msec); timeInfo[i] = cal.getTime(); } // Parse Image Data /* * Close Random access file and switch to scanner first store pos * then move to correct point. */ long pos = in.getFilePointer(); in.close(); FileInputStream fIn = new FileInputStream(file); fIn.skip(pos); BufferedInputStream bIn = new BufferedInputStream(fIn); Scanner sIn = new Scanner(bIn); short[][][] holder = new short[tot][wide][high]; JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); StatusBarPanel stat = new StatusBarPanel(); stat.setMaximum(high); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(stat, BorderLayout.CENTER); f.setSize(200, 60); f.setVisible(true); for (int i = 0; i < tot; i++) { // Skip over the heading values stat.setStatusMessage("Loading " + i + " of " + tot); sIn.useDelimiter("\n"); sIn.next(); sIn.next(); sIn.next(); if (i != 0) { sIn.next(); } sIn.reset(); for (int y = 0; y < high; y++) { stat.setValue(y); sIn.nextInt(); for (int x = 0; x < wide; x++) { holder[i][x][y] = sIn.nextShort(); } } addData(timeInfo[i], holder[i]); } // FrameFactroy.getFrame(new DynamicRangeImage(data[0])); // Start Image Data } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.oscarehr.web.Cds4ReportUIBean.java
public String getDateRangeForDisplay() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar displayEndDate = (GregorianCalendar) endDate.clone(); displayEndDate.add(GregorianCalendar.MONTH, -1); return (StringEscapeUtils.escapeHtml(simpleDateFormat.format(startDate.getTime()) + " to " + simpleDateFormat.format(displayEndDate.getTime()) + " (inclusive)")); }
From source file:it.cineca.iris.restclient.main.Command.java
/** * Utiliy method//from w w w .j av a2 s .c o m * * @param min * @param max * @return random date as string. */ private String getRandomDate(int min, int max) { GregorianCalendar gc = new GregorianCalendar(); int year = randBetween(min, max); gc.set(gc.YEAR, year); int dayOfYear = randBetween(1, gc.getActualMaximum(gc.DAY_OF_YEAR)); gc.set(gc.DAY_OF_YEAR, dayOfYear); SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy"); String dateFormatted = fmt.format(gc.getTime()); System.out.println("Random Date: " + dateFormatted); return dateFormatted; }
From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRBean.java
@Transactional public int getCountIVRCallSessionsInLastDays(int days) { days = days < 0 ? 0 : days;//from w w w .j a v a 2 s . c o m GregorianCalendar end = new GregorianCalendar(); GregorianCalendar lastMidnight = new GregorianCalendar(end.get(GregorianCalendar.YEAR), end.get(GregorianCalendar.MONTH), end.get(GregorianCalendar.DAY_OF_MONTH)); Date start = addToDate(lastMidnight.getTime(), GregorianCalendar.DAY_OF_MONTH, (int) (days - 1) * (-1)); return ivrDao.countIVRCallSessionsCreatedBetweenDates(start, end.getTime()); }
From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRBean.java
@Transactional public int getCountIVRCallsInLastDays(int days) { days = days < 0 ? 0 : days;//from w w w . ja v a2 s. co m GregorianCalendar end = new GregorianCalendar(); GregorianCalendar lastMidnight = new GregorianCalendar(end.get(GregorianCalendar.YEAR), end.get(GregorianCalendar.MONTH), end.get(GregorianCalendar.DAY_OF_MONTH)); Date start = addToDate(lastMidnight.getTime(), GregorianCalendar.DAY_OF_MONTH, (int) (days - 1) * (-1)); return ivrDao.countIVRCallsCreatedBetweenDates(start, end.getTime()); }
From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRBean.java
@Transactional public int getCountIVRCallsInLastDaysWithStatus(int days, IVRCallStatus status) { days = days < 0 ? 0 : days;/*from w w w. j a v a 2 s.com*/ GregorianCalendar end = new GregorianCalendar(); GregorianCalendar lastMidnight = new GregorianCalendar(end.get(GregorianCalendar.YEAR), end.get(GregorianCalendar.MONTH), end.get(GregorianCalendar.DAY_OF_MONTH)); Date start = addToDate(lastMidnight.getTime(), GregorianCalendar.DAY_OF_MONTH, (int) (days - 1) * (-1)); return ivrDao.countIVRCallsCreatedBetweenDatesWithStatus(start, end.getTime(), status); }
From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRBean.java
@Transactional public List<IVRCallStatusStat> getIVRCallStatusStatsFromLastDays(int days) { days = days < 0 ? 0 : days;// www.ja v a 2 s . c o m GregorianCalendar end = new GregorianCalendar(); GregorianCalendar lastMidnight = new GregorianCalendar(end.get(GregorianCalendar.YEAR), end.get(GregorianCalendar.MONTH), end.get(GregorianCalendar.DAY_OF_MONTH)); Date start = addToDate(lastMidnight.getTime(), GregorianCalendar.DAY_OF_MONTH, (int) (days - 1) * (-1)); return ivrDao.getIVRCallStatusStatsBetweenDates(start, end.getTime()); }
From source file:org.motechproject.mobile.omp.manager.intellivr.IntellIVRBean.java
@Transactional public List<IVRCallSession> getIVRCallSessionsInLastDays(int days) { days = days < 0 ? 0 : days;/*from ww w . jav a 2 s .co m*/ GregorianCalendar end = new GregorianCalendar(); GregorianCalendar lastMidnight = new GregorianCalendar(end.get(GregorianCalendar.YEAR), end.get(GregorianCalendar.MONTH), end.get(GregorianCalendar.DAY_OF_MONTH)); Date start = addToDate(lastMidnight.getTime(), GregorianCalendar.DAY_OF_MONTH, (int) (days - 1) * (-1)); return ivrDao.loadIVRCallSessionsCreatedBetweenDates(start, end.getTime()); }