try{ ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), 0); ZipFile zf = new ZipFile(ai.sourceDir); ZipEntry ze = zf.getEntry("classes.dex"); long time = ze.getTime(); String s = SimpleDateFormat.getInstance().format(new java.util.Date(time)); zf.close(); }catch(Exception e){ }
DateFormat.getInstance().format(currentTimeMillis);
public Date convert(Object src) { if(src == null){ return null; } if(Date.class.isAssignableFrom(src.getClass())){ return (Date) src; } else if(Long.class.isAssignableFrom(src.getClass())){ return new Date((Long) src); } else if(String.class.isAssignableFrom(src.getClass())){ try { return DateFormat.getInstance().parse(src.toString()); } catch (ParseException e) { throw new MappingException(e); } } throw new MappingException("can not map a " + src.getClass() + " to " + Date.class.getName()); } }
return DateFormat.getTimeInstance().format((Date) o); return DateFormat.getInstance().format((Date) o);
@Override public Date convert(byte[] source) { if (ObjectUtils.isEmpty(source)) { return null; } String value = toString(source); try { return new Date(NumberUtils.parseNumber(value, Long.class)); } catch (NumberFormatException nfe) { // ignore } try { return DateFormat.getInstance().parse(value); } catch (ParseException e) { // ignore } throw new IllegalArgumentException(String.format("Cannot parse date out of %s", Arrays.toString(source))); } }
CommandResponse(String sender, String contentType, int status, String page, String tokenAccessor, String debugInfo, String header, GfJsonObject content, String footer, boolean failedToPersist, Path fileToDownload) { this.sender = sender; this.contentType = contentType; this.status = status; this.page = page; this.tokenAccessor = tokenAccessor; this.debugInfo = debugInfo; this.data = new LegacyData(header, content, footer); this.when = DateFormat.getInstance().format(new java.util.Date()); this.version = GemFireVersion.getGemFireVersion(); this.failedToPersist = failedToPersist; if (fileToDownload != null) { this.fileToDownload = fileToDownload.toString(); } else { this.fileToDownload = null; } this.isLegacy = true; }
@SuppressWarnings("DefaultCharset") protected final void setupWriter() { String outputFile = settings.getOutputFile(); if (outputFile == null || outputFile.equals("::null") || outputFile.equals("/dev/null")) return; if (!outputFile.equals("::stdout")) { String outputDir = settings.getOutputDir(); String output = (outputDir != null ? outputDir + File.separator : "") + outputFile; outputFile = templateOutputFileName(output); infoPrint("Redirecting output to " + outputFile); } out = WRITER_MAP.get(outputFile); if (out == null) { if (outputFile.equals("::stdout")) { out = new PrintWriter(System.out); } else { if (settings.getFileRollMilliseconds() > 0) { out = new PrintWriter(new BufferedWriter( TraceOutputWriter.rollingFileWriter(new File(outputFile), settings) )); } else { out = new PrintWriter(new BufferedWriter(TraceOutputWriter.fileWriter(new File(outputFile), settings))); } } WRITER_MAP.put(outputFile, out); out.append("### BTrace Log: " + DateFormat.getInstance().format(new Date()) + "\n\n"); startFlusher(); } outputName = outputFile; }
format = NumberFormat.getInstance(); } else if (arg instanceof Date) { format = DateFormat.getInstance(); } else { buffer.append(arg);
@Override public Response serve() { String traces[] = new JStackCollectorTask().invokeOnAllNodes()._result; nodes = new StackSummary[H2O.CLOUD.size()]; for( int i=0; i<nodes.length; i++ ) nodes[i] = new StackSummary(H2O.CLOUD._memary[i].toString(),traces[i]); node_name = H2O.SELF.toString(); cloud_name = H2O.NAME; time = DateFormat.getInstance().format(new Date()); for( int i=0; i<nodes.length; i++ ) Log.debug(Log.Tag.Sys.WATER,nodes[i].name,nodes[i].traces); return Response.done(this); }
public void validate() throws InvalidSessionException { //check for stopped: if (isStopped()) { //timestamp is set, so the session is considered stopped: String msg = "Session with id [" + getId() + "] has been " + "explicitly stopped. No further interaction under this session is " + "allowed."; throw new StoppedSessionException(msg); } //check for expiration if (isTimedOut()) { expire(); //throw an exception explaining details of why it expired: Date lastAccessTime = getLastAccessTime(); long timeout = getTimeout(); Serializable sessionId = getId(); DateFormat df = DateFormat.getInstance(); String msg = "Session with id [" + sessionId + "] has expired. " + "Last access time: " + df.format(lastAccessTime) + ". Current time: " + df.format(new Date()) + ". Session timeout is set to " + timeout / MILLIS_PER_SECOND + " seconds (" + timeout / MILLIS_PER_MINUTE + " minutes)"; if (log.isTraceEnabled()) { log.trace(msg); } throw new ExpiredSessionException(msg); } }
@Override public void execImpl() { ProfileCollectorTask.NodeProfile profiles[] = new ProfileCollectorTask(depth).invokeOnAllNodes()._result; nodes = new ProfileSummary[H2O.CLOUD.size()]; for( int i=0; i<nodes.length; i++ ) nodes[i] = new ProfileSummary(H2O.CLOUD._memary[i].toString(),profiles[i]); node_name = H2O.SELF.toString(); cloud_name = H2O.NAME; time = DateFormat.getInstance().format(new Date()); for( int i=0; i<nodes.length; i++ ) { Log.info(nodes[i].name); for (int j = 0; j < nodes[i].profile.counts.length; ++j) { Log.info(nodes[i].profile.counts[j]); Log.info(nodes[i].profile.stacktraces[j]); } } }
case ValueMetaInterface.TYPE_DATE: try { data.nullIf[i] = DateFormat.getInstance().parse( meta.getValueDefault()[i] ); } catch ( Exception e ) {
.recycleWith(rowHandler) .forList()) .addItem(getInstance().format(new Date()), dataBindingRepositoryPresenterOf(String.class) .layout(R.layout.footer) .itemId(BR.string)
/** * Converts the string to a date, using the default date format. * * @param pString the string to convert * @return the date * @see DateFormat * @see DateFormat#getInstance() */ public static Date toDate(String pString) { // Default return toDate(pString, DateFormat.getInstance()); }
break; case RssInputField.COLUMN_PUB_DATE: valueString = item.getPubDate() == null ? "" : DateFormat.getInstance().format( item.getPubDate() ); break; default:
public Date convert(Object src) { if(src == null){ return null; } if(Date.class.isAssignableFrom(src.getClass())){ return (Date) src; } else if(Long.class.isAssignableFrom(src.getClass())){ return new Date((Long) src); } else if(String.class.isAssignableFrom(src.getClass())){ try { return DateFormat.getInstance().parse(src.toString()); } catch (ParseException e) { throw new MappingException(e); } } throw new MappingException("can not map a " + src.getClass() + " to " + Date.class.getName()); } }
@Test public void testDefault() throws ParseException { final String formatted = DateStringLookup.INSTANCE.lookup(null); DateFormat.getInstance().parse(formatted); // throws ParseException }
@Test public void testToDate() { long time = System.currentTimeMillis(); Date now = new Date(time - time % 60000); // Default format seems to have no seconds.. Date date = StringUtil.toDate(DateFormat.getInstance().format(now)); assertNotNull(date); assertEquals(now, date); }
public void validate() throws InvalidSessionException { //check for stopped: if (isStopped()) { //timestamp is set, so the session is considered stopped: String msg = "Session with id [" + getId() + "] has been " + "explicitly stopped. No further interaction under this session is " + "allowed."; throw new StoppedSessionException(msg); } //check for expiration if (isTimedOut()) { expire(); //throw an exception explaining details of why it expired: Date lastAccessTime = getLastAccessTime(); long timeout = getTimeout(); Serializable sessionId = getId(); DateFormat df = DateFormat.getInstance(); String msg = "Session with id [" + sessionId + "] has expired. " + "Last access time: " + df.format(lastAccessTime) + ". Current time: " + df.format(new Date()) + ". Session timeout is set to " + timeout / MILLIS_PER_SECOND + " seconds (" + timeout / MILLIS_PER_MINUTE + " minutes)"; if (log.isTraceEnabled()) { log.trace(msg); } throw new ExpiredSessionException(msg); } }
@Test public void importStaticMethod() throws RegistrationException, InitialisationException { assertThat(evaluate("dateFormat()"), is(DateFormat.getInstance())); }