Example usage for java.util Date toGMTString

List of usage examples for java.util Date toGMTString

Introduction

In this page you can find the example usage for java.util Date toGMTString.

Prototype

@Deprecated
public String toGMTString() 

Source Link

Document

Creates a string representation of this Date object of the form:
 d mon yyyy hh:mm:ss GMT
where:
  • d is the day of the month ( 1 through 31 ), as one or two decimal digits.

    Usage

    From source file:com.radadev.xkcd.Comics.java

    public static final boolean setLastUpdate(Context context, Date date) {
        Editor editor = context.getSharedPreferences("info", Context.MODE_WORLD_READABLE).edit();
        editor.putString(KEY_LAST_UPDATE, date.toGMTString());
        return editor.commit();
    }
    

    From source file:org.apache.hadoop.hbase.mob.MobUtils.java

    /**
     * Cleans the expired mob files./*from  ww  w .j ava  2s .  co  m*/
     * Cleans the files whose creation date is older than (current - columnFamily.ttl), and
     * the minVersions of that column family is 0.
     * @param fs The current file system.
     * @param conf The current configuration.
     * @param tableName The current table name.
     * @param columnDescriptor The descriptor of the current column family.
     * @param cacheConfig The cacheConfig that disables the block cache.
     * @param current The current time.
     * @throws IOException
     */
    public static void cleanExpiredMobFiles(FileSystem fs, Configuration conf, TableName tableName,
            HColumnDescriptor columnDescriptor, CacheConfig cacheConfig, long current) throws IOException {
        long timeToLive = columnDescriptor.getTimeToLive();
        if (Integer.MAX_VALUE == timeToLive) {
            // no need to clean, because the TTL is not set.
            return;
        }
    
        Date expireDate = new Date(current - timeToLive * 1000);
        expireDate = new Date(expireDate.getYear(), expireDate.getMonth(), expireDate.getDate());
        LOG.info("MOB HFiles older than " + expireDate.toGMTString() + " will be deleted!");
    
        FileStatus[] stats = null;
        Path mobTableDir = FSUtils.getTableDir(getMobHome(conf), tableName);
        Path path = getMobFamilyPath(conf, tableName, columnDescriptor.getNameAsString());
        try {
            stats = fs.listStatus(path);
        } catch (FileNotFoundException e) {
            LOG.warn("Failed to find the mob file " + path, e);
        }
        if (null == stats) {
            // no file found
            return;
        }
        List<StoreFile> filesToClean = new ArrayList<StoreFile>();
        int deletedFileCount = 0;
        for (FileStatus file : stats) {
            String fileName = file.getPath().getName();
            try {
                MobFileName mobFileName = null;
                if (!HFileLink.isHFileLink(file.getPath())) {
                    mobFileName = MobFileName.create(fileName);
                } else {
                    HFileLink hfileLink = HFileLink.buildFromHFileLinkPattern(conf, file.getPath());
                    mobFileName = MobFileName.create(hfileLink.getOriginPath().getName());
                }
                Date fileDate = parseDate(mobFileName.getDate());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Checking file " + fileName);
                }
                if (fileDate.getTime() < expireDate.getTime()) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(fileName + " is an expired file");
                    }
                    filesToClean.add(new StoreFile(fs, file.getPath(), conf, cacheConfig, BloomType.NONE));
                }
            } catch (Exception e) {
                LOG.error("Cannot parse the fileName " + fileName, e);
            }
        }
        if (!filesToClean.isEmpty()) {
            try {
                removeMobFiles(conf, fs, tableName, mobTableDir, columnDescriptor.getName(), filesToClean);
                deletedFileCount = filesToClean.size();
            } catch (IOException e) {
                LOG.error("Failed to delete the mob files " + filesToClean, e);
            }
        }
        LOG.info(deletedFileCount + " expired mob files are deleted");
    }
    

    From source file:com.gistlabs.mechanize.cache.HttpCacheFilterTest.java

    @SuppressWarnings("deprecation")
    @Test// ww w  . j  a  v  a  2s. c o m
    public void confirmDateUtil() throws DateParseException {
        Date date = DateUtils.parseDate("Sun, 09 Aug 2009 01:56:14 GMT");
        assertEquals("9 Aug 2009 01:56:14 GMT", date.toGMTString());
    }
    

    From source file:edu.harvard.i2b2.fhirserver.ejb.AuthenticationService.java

    private boolean isExpired(Date inputDate) {
    
        Date current = new Date();
        boolean result = current.after(inputDate) ? true : false;
        logger.info("current Date:" + current.toGMTString() + "\ninputDate:" + inputDate.toGMTString()
                + "\nisExpired?:" + result);
        return result;
    }
    

    From source file:com.android.email.mail.store.imap.ImapStringTest.java

    public void testGetDateOrNull() {
        final ImapString date = new ImapSimpleString("01-Jan-2009 11:34:56 -0100");
    
        assertTrue(date.isDate());/* w  ww.  j  a v a2s  . c  o m*/
        Date d = date.getDateOrNull();
        assertNotNull(d);
        assertEquals("1 Jan 2009 12:34:56 GMT", d.toGMTString());
    
        final ImapString nonDate = new ImapSimpleString("1234");
        assertFalse(nonDate.isDate());
        assertNull(nonDate.getDateOrNull());
    }
    

    From source file:org.atomserver.core.EntryURIHelperTest.java

    @SuppressWarnings("deprecation")
    public void testDate2() {
        try {/*from w  w  w  .j a  v a 2  s.  c om*/
            String iri = "http://foobar:7890/" + baseURI + "/widgets/acme/?updated-min=2007-11-30T23:59:59:000Z";
            handler.getFeedTarget(new MockRequestContext(serviceContext, "GET", iri));
        } catch (IllegalArgumentException ee) {
            log.error(ee);
        }
    
        try {
            // This date is WRONG -- should be 59.000Z !!!
            //  NOTE: it should fail -- but it does NOT
            String ddd = "2007-11-30T23:59:59:000Z";
            Date upmin = AtomDate.parse(ddd);
            log.debug("*********2007-11-30T23:59:59:000Z************ upmin= " + upmin);
        } catch (IllegalArgumentException ee) {
            log.error(ee);
        }
    
        String ddd2 = "2007-11-30T23:59:59.000Z";
        Date upmin2 = AtomDate.parse(ddd2);
        log.debug("********2007-11-30T23:59:59.000Z************* upmin2= " + upmin2);
        log.debug("********2007-11-30T23:59:59.000Z************* upmin2 GMT= " + upmin2.toGMTString());
    
        String iri2 = "http://stgbrss:7890/" + baseURI + "/widgets/acme?updated-min=2007-11-30T23:59:59+06:00";
        FeedTarget entryURIData = handler.getFeedTarget(new MockRequestContext(serviceContext, "GET", iri2));
        Date upmin = entryURIData.getUpdatedMinParam();
        log.debug("********2007-11-30T23:59:59+06:00************* upmin= " + upmin);
        log.debug("********2007-11-30T23:59:59+06:00************* upmin GMT= " + upmin.toGMTString());
    }
    

    From source file:biz.taoconsulting.dominodav.methods.PROPFIND.java

    /**
     * (non-Javadoc)/*from w w w .j  av a  2 s.co m*/
     * 
     * @see biz.taoconsulting.dominodav.methods.AbstractDAVMethod#action()
     */
    @SuppressWarnings("deprecation")
    protected void action() throws Exception { // TODO: cleanup action method by
        // refactoring -- too messy
        boolean withoutChildren = true; // Resource only, no children
        IDAVRepository rep = this.getRepository();
        IDAVResource resource;
        HttpServletResponse resp = this.getResp();
    
        // Resource-Path is stripped by the repository name!
        String curPath = null;
        String curURI = null;
    
        try {
            curPath = (String) this.getHeaderValues().get("resource-path");
            if (curPath == null || curPath.equals("")) {
                curPath = "/";
            }
            // If Depth is missing it might throw an error, so we assume 0 then
            String depth = this.getHeaderValues().get("Depth");
            if (depth != null && depth.equals("0")) {
                withoutChildren = true;
            } else {
                withoutChildren = false;
            }
            // uri is the unique identifier on the host includes servlet and
            // repository but not server
            curURI = (String) this.getHeaderValues().get("uri");
    
        } catch (Exception e) {
            LOGGER.error(e);
            withoutChildren = true; // No recursive call to propfind in a error
            // condition
        }
    
        LOGGER.info("PROPFIND for path:[" + curPath + "] and URI:" + curURI);
    
        IDAVXMLResponse xr = DavXMLResponsefactory.getXMLResponse(null, false);
        if (this.redirectedFromGet) {
            // Determine the style
            String xsltStyle = null;
            if (rep instanceof DAVRepositoryMETA) {
                xsltStyle = WebDavManager.getManager(null).getRootPropfindStyle();
            } else {
                xsltStyle = WebDavManager.getManager(null).getPropfindStyle();
            }
            xr = DavXMLResponsefactory.getXMLResponse(xsltStyle, true);
    
        } else {
            xr = DavXMLResponsefactory.getXMLResponse(null, true);
        }
        // LOGGER.info("xr OK");
        // xr = DavXMLResponsefactory.getXMLResponse(null, false);
    
        try {
    
            // Here we need to retrieve the path without the repository name!
            resource = rep.getResource(curURI, withoutChildren);
    
            if (resource == null) {
                // LOGGER.info("Resource is null");
                this.setErrorMessage("<h1>404 - Resource not found</h1>", HttpServletResponse.SC_NOT_FOUND);
    
                String result = this.getErrorMessage();
                resp.setContentLength(result.length());
                PrintWriter out = resp.getWriter();
                out.write(result);
                out.close();
    
            } else {
    
                if (!resource.isCollection()) {
                    // LOGGER.info("Resource is not a collection");
                    this.getResp().setHeader("ETag", resource.getETag());
                }
                // Modified by EC
                // LOGGER.info("Further.....");
    
                java.util.Date dt = new java.util.Date();
                this.getResp().setHeader("Last-Modified", dt.toGMTString());
                this.getResp().setHeader("Cache-Control", "no-cache");
                dt.setYear(70);
                this.getResp().setHeader("Expires", dt.toGMTString());
                this.getResp().setHeader("Server", "Microsoft-IIS/6.0");
                this.getResp().setHeader("Public-Extension", "http://schemas.microsoft.com/repl-2");
                this.getResp().setHeader("MicrosoftSharePointTeamServices", "12.0.0.6210");
                this.getResp().setHeader("Set-Cookie", "WSS_KeepSessionAuthenticated=80; path=" + curURI);
    
                // End Mody by EC
                xr.openTag("multistatus");
                resource.addToDavXMLResponse(xr);
                xr.auxTag("username", rep.getCredentials().getUserName());
                xr.addComment("Called method : PROPFIND");
                xr.closeDocument();
                // LOGGER.info("Close doc");
                // Ugly hack: Domino closes connections on status 207
                // and Win7 has a problem with it
    
                /*
                 * if (this.redirectedFromGet ||
                 * this.cameFromWindows7webDAVredir(this.getReq())) {
                 * this.setHTTPStatus(HttpServletResponse.SC_OK);
                 * resp.setStatus(HttpServletResponse.SC_OK); } else {
                 * this.setHTTPStatus(DAVProperties.STATUS_MULTIPART);
                 * resp.setStatus(DAVProperties.STATUS_MULTIPART,
                 * DAVProperties.STATUS_MULTIPART_STRING); }
                 */
    
                this.setHTTPStatus(DAVProperties.STATUS_MULTIPART);
                resp.setStatus(DAVProperties.STATUS_MULTIPART, DAVProperties.STATUS_MULTIPART_STRING);
                resp.setHeader("Connection", "keep-alive");
    
                resp.setContentType(DAVProperties.TYPE_XML);
                // resp.setContentType("text/xml");
                // resp.setHeader("content-encoding", "utf-8");
                // resp.setContentLength(xr.getXMLBytes().length);
                // ServletOutputStream out = this.getOutputStream();
                // out.write(xr.getXMLBytes());
                // out.close();
                String result = xr.toString();
                resp.setContentLength(result.length());
                PrintWriter out = resp.getWriter();
                out.write(result);
                out.close();
            }
    
        } catch (DAVNotFoundException exc) {
            // LOGGER.error(exc);
            this.setErrorMessage("<h1>404 - Resource not found</h1>", HttpServletResponse.SC_NOT_FOUND);
            String result = this.getErrorMessage();
            resp.setContentLength(result.length());
            PrintWriter out = resp.getWriter();
            out.write(result);
            out.close();
        } catch (IOException e) {
            // LOGGER.error(e);
            this.setErrorMessage("<h1>500 - We screwed up</h1><h2>" + e.getMessage() + "</h2>",
                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    
    }
    

    From source file:com.ikanow.aleph2.management_db.mongodb.services.IkanowV1SyncService_Buckets.java

    /** Takes a collection of results from the management side-channel, and uses it to update a harvest node
     * @param key - source key / bucket id//from   ww  w . jav a  2  s.com
     * @param status_messages
     * @param source_db
     */
    protected static CompletableFuture<Boolean> updateV1SourceStatus(final Date main_date, final String key,
            final Collection<BasicMessageBean> status_messages, final boolean set_approved_state,
            final ICrudService<JsonNode> source_db) {
        final String message_block = status_messages.stream().map(msg -> {
            return "[" + msg.date() + "] " + msg.source() + " (" + msg.command() + "): "
                    + (msg.success() ? "INFO" : "ERROR") + ": " + msg.message();
        }).collect(Collectors.joining("\n"));
    
        final boolean any_errors = status_messages.stream().anyMatch(msg -> !msg.success());
    
        @SuppressWarnings("deprecation")
        final CommonUpdateComponent<JsonNode> update_1 = CrudUtils.update()
                .set("harvest.harvest_status", (any_errors ? "error" : "success"))
                .set("harvest.harvest_message", "[" + main_date.toGMTString() + "] Bucket synchronization:\n"
                        + (message_block.isEmpty() ? "(no messages)" : message_block));
    
        final UpdateComponent<JsonNode> update = set_approved_state ? update_1.set("isApproved", !any_errors)
                : update_1;
    
        final SingleQueryComponent<JsonNode> v1_query = CrudUtils.allOf().when("key", key);
        final CompletableFuture<Boolean> update_res = source_db.updateObjectBySpec(v1_query, Optional.empty(),
                update);
    
        return update_res;
    }
    

    From source file:com.intellectualcrafters.plot.commands.DebugExec.java

    @Override
    public boolean execute(final PlotPlayer player, final String... args) {
        final List<String> allowed_params = Arrays.asList("analyze", "reset-modified", "stop-expire",
                "start-expire", "show-expired", "update-expired", "seen", "trim-check");
        if (args.length > 0) {
            final String arg = args[0].toLowerCase();
            switch (arg) {
            case "analyze": {
                final Plot plot = MainUtil.getPlot(player.getLocation());
                HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
                    @Override//w ww  .  j a  va  2 s.com
                    public void run() {
                        List<Double> result = new ArrayList<>();
                        result.add(Math.round(value.air * 100) / 100d);
                        result.add(Math.round(value.changes * 100) / 100d);
                        result.add(Math.round(value.complexity * 100) / 100d);
                        result.add(Math.round(value.data * 100) / 100d);
                        result.add(Math.round(value.faces * 100) / 100d);
                        result.add(Math.round(value.air * 100) / 100d);
                        result.add(Math.round(value.variety * 100) / 100d);
                        Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
                        FlagManager.addPlotFlag(plot, flag);
                    }
                });
                return true;
            }
            case "stop-expire": {
                if (ExpireManager.task != -1) {
                    Bukkit.getScheduler().cancelTask(ExpireManager.task);
                } else {
                    return MainUtil.sendMessage(player, "Task already halted");
                }
                ExpireManager.task = -1;
                return MainUtil.sendMessage(player, "Cancelled task.");
            }
            case "remove-flag": {
                if (args.length != 2) {
                    MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec reset-flat <flag>");
                    return false;
                }
                String flag = args[1];
                for (Plot plot : PS.get().getPlots()) {
                    if (FlagManager.getPlotFlag(plot, flag) != null) {
                        FlagManager.removePlotFlag(plot, flag);
                    }
                }
                return MainUtil.sendMessage(player, "Cleared flag: " + flag);
            }
            case "start-rgar": {
                if (args.length != 2) {
                    PS.log("&cInvalid syntax: /plot debugexec start-rgar <world>");
                    return false;
                }
                boolean result;
                if (!PS.get().isPlotWorld(args[1])) {
                    MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]);
                    return false;
                }
                if (BukkitHybridUtils.regions != null) {
                    result = ((BukkitHybridUtils) (HybridUtils.manager)).scheduleRoadUpdate(args[1],
                            BukkitHybridUtils.regions, 0);
                } else {
                    result = HybridUtils.manager.scheduleRoadUpdate(args[1], 0);
                }
                if (!result) {
                    PS.log("&cCannot schedule mass schematic update! (Is one already in progress?)");
                    return false;
                }
                return true;
            }
            case "stop-rgar": {
                if (((BukkitHybridUtils) (HybridUtils.manager)).task == 0) {
                    PS.log("&cTASK NOT RUNNING!");
                    return false;
                }
                ((BukkitHybridUtils) (HybridUtils.manager)).task = 0;
                Bukkit.getScheduler().cancelTask(((BukkitHybridUtils) (HybridUtils.manager)).task);
                PS.log("&cCancelling task...");
                while (BukkitHybridUtils.chunks.size() > 0) {
                    ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
                    BukkitHybridUtils.chunks.remove(0);
                    HybridUtils.manager.regenerateRoad(BukkitHybridUtils.world, chunk, 0);
                    ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk);
                }
                PS.log("&cCancelled!");
                return true;
            }
            case "start-expire": {
                if (ExpireManager.task == -1) {
                    ExpireManager.runTask();
                } else {
                    return MainUtil.sendMessage(player, "Plot expiry task already started");
                }
                return MainUtil.sendMessage(player, "Started plot expiry task");
            }
            case "update-expired": {
                if (args.length > 1) {
                    final String world = args[1];
                    if (!BlockManager.manager.isWorld(world)) {
                        return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
                    }
                    MainUtil.sendMessage(player, "Updating expired plot list");
                    ExpireManager.updateExpired(args[1]);
                    return true;
                }
                return MainUtil.sendMessage(player, "Use /plot debugexec update-expired <world>");
            }
            case "show-expired": {
                if (args.length > 1) {
                    final String world = args[1];
                    if (!BlockManager.manager.isWorld(world)) {
                        return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
                    }
                    if (!ExpireManager.expiredPlots.containsKey(args[1])) {
                        return MainUtil.sendMessage(player, "No task for world: " + args[1]);
                    }
                    MainUtil.sendMessage(player,
                            "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
                    for (final Plot plot : ExpireManager.expiredPlots.get(args[1])) {
                        MainUtil.sendMessage(player, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";"
                                + UUIDHandler.getName(plot.owner) + " : " + ExpireManager.dates.get(plot.owner));
                    }
                    return true;
                }
                return MainUtil.sendMessage(player, "Use /plot debugexec show-expired <world>");
            }
            case "seen": {
                if (args.length != 2) {
                    return MainUtil.sendMessage(player, "Use /plot debugexec seen <player>");
                }
                final UUID uuid = UUIDHandler.getUUID(args[1]);
                if (uuid == null) {
                    return MainUtil.sendMessage(player, "player not found: " + args[1]);
                }
                final OfflinePlotPlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
                if ((op == null) || (op.getLastPlayed() == 0)) {
                    return MainUtil.sendMessage(player, "player hasn't connected before: " + args[1]);
                }
                final Timestamp stamp = new Timestamp(op.getLastPlayed());
                final Date date = new Date(stamp.getTime());
                MainUtil.sendMessage(player, "PLAYER: " + args[1]);
                MainUtil.sendMessage(player, "UUID: " + uuid);
                MainUtil.sendMessage(player, "Object: " + date.toGMTString());
                MainUtil.sendMessage(player, "GMT: " + date.toGMTString());
                MainUtil.sendMessage(player, "Local: " + date.toLocaleString());
                return true;
            }
            case "trim-check": {
                if (args.length != 2) {
                    MainUtil.sendMessage(player, "Use /plot debugexec trim-check <world>");
                    MainUtil.sendMessage(player, "&7 - Generates a list of regions to trim");
                    return MainUtil.sendMessage(player, "&7 - Run after plot expiry has run");
                }
                final String world = args[1];
                if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(args[1])) {
                    return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
                }
                final ArrayList<ChunkLoc> empty = new ArrayList<>();
                final boolean result = Trim.getTrimRegions(empty, world, new Runnable() {
                    @Override
                    public void run() {
                        Trim.sendMessage("Processing is complete! Here's how many chunks would be deleted:");
                        Trim.sendMessage(" - MCA #: " + empty.size());
                        Trim.sendMessage(" - CHUNKS: " + (empty.size() * 1024) + " (max)");
                        Trim.sendMessage("Exporting log for manual approval...");
                        final File file = new File(PS.get().IMP.getDirectory() + File.separator + "trim.txt");
                        PrintWriter writer;
                        try {
                            writer = new PrintWriter(file);
                            for (final ChunkLoc loc : empty) {
                                writer.println(world + "/region/r." + loc.x + "." + loc.z + ".mca");
                            }
                            writer.close();
                            Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'");
                        } catch (final FileNotFoundException e) {
                            e.printStackTrace();
                            Trim.sendMessage("File failed to save! :(");
                        }
                        Trim.sendMessage("How to get the chunk coords from a region file:");
                        Trim.sendMessage(
                                " - Locate the x,z values for the region file (the two numbers which are separated by a dot)");
                        Trim.sendMessage(" - Multiply each number by 32; this gives you the starting position");
                        Trim.sendMessage(" - Add 31 to each number to get the end position");
                    }
                });
                if (!result) {
                    MainUtil.sendMessage(player, "Trim task already started!");
                }
                return result;
            }
            }
        }
        MainUtil.sendMessage(player,
                "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">");
        return true;
    }
    

    From source file:com.zimbra.cs.service.authenticator.CertUtil.java

    private void printValidity(PrintStream outStream) {
        Date notBefore = cert.getNotBefore();
        Date notAfter = cert.getNotAfter();
    
        outStream.format("Validity\n");
        outStream.format("    Not Before: %s\n", notBefore.toGMTString());
        outStream.format("    Not After : %s\n", notAfter.toGMTString());
    }