Is there a destructor for Java?

Is there a destructor for Java? I don't seem to be able to find any documentation on this. If there isn't, how can I achieve the same effect? To make my question more specific, I am writing an application that deals with data, and the specification say that there should be a 'reset' button that brings the application back to its original just launched state. However, all data

有没有Java的析构函数?

有没有Java的析构函数? 我似乎无法找到关于此的任何文档。 如果没有,我怎样才能达到同样的效果? 为了让我的问题更具体,我正在编写一个处理数据的应用程序,并且规范说应该有一个“重置”按钮,使应用程序恢复到刚刚启动的状态。 但是,除非应用程序已关闭或按下重置按钮,否则所有数据都必须“有效”。 作为一名C / C ++程序员,我认为这将是微不足道的实施。 (因此我计划最后实现它。)我组织了我的程序,以便所有可重

Easiest way to cause memory leak in Java?

Possible Duplicate: Creating a memory leak with Java What's the easiest way to cause a java memory leak? You cannot really "leak memory" in Java unless you: intern strings generate classes leak memory in the native code called by jni keep references to things that you do not want in some forgotten or obscure place. I take it that you are interested in the last case.

在Java中导致内存泄漏的最简单方法是什么?

可能重复: 用Java创建内存泄漏 什么是导致java内存泄漏的最简单方法? 你不能真正“泄漏”Java中的内存,除非你: 实习生字符串 生成类 在由jni调用的本地代码中泄漏内存 在一些被遗忘或晦涩的地方继续提及你不想要的东西。 我认为你对最后一种情况感兴趣。 常见的情况是: 听众,特别是内部类 缓存。 一个很好的例子是: 构建一个Swing GUI,它可以启动无限数量的模式窗口; 模态窗口在初始化时会做这

Why do heap memory usage and number of loaded classes keep increasing?

I am using JVM Explorer - link to JVM Explorer , to profile my Spring application. I have following questions about it. Why 'Used Heap Memory' keeps increasing even after the application has started up and have not received any requests yet? (Image 1) Why even after garbage collection and before receiving any requests 'Used Heap Memory' keeps increasing? (Image2) Why afte

为什么堆内存使用率和加载的类数不断增加?

我正在使用JVM Explorer - 链接到JVM资源管理器,来分析我的Spring应用程序。 我有关于它的以下问题。 为什么即使在应用程序启动并且还没有收到任何请求之后,“使用的堆内存”仍然在不断增加? (图1) 为什么即使在垃圾回收之后,在接收到任何请求之前,“已使用的堆内存”不断增加? (图像2) 为什么在垃圾回收之后,通过向应用程序发送一些请求来加载类的数量正在增加? 应用程序是否应该使用以前的类? 为什么它几

Is Go subject to the same subtle memory

Here are the facts: the language Go has a garbage collector. Java has a garbage collection a lot of Java programs have (subtle or not) memory leaks As an example of a Java program that has memory leaks (not for the faint of heart, the question may shake your beliefs), see here about a little Java program called Tomcat that even has a "find leaks" button: Is there a way to avoid

Go会受到相同的微妙记忆

这里是事实: 语言Go有一个垃圾收集器。 Java有一个垃圾收集 很多Java程序都有(微妙或不微)内存泄漏 作为一个有内存泄漏的Java程序的例子(不是心存疑虑,这个问题可能会动摇你的信念),在这里看到一个叫做Tomcat的Java程序,它甚至有一个“find leaks”按钮:有没有办法避免在Tomcat中取消部署内存泄漏? 所以我想知道:使用Go编写的程序是否会展示与使用Java编写的某些程序展现相同类型的(微妙的或不是)内存泄漏

Java Date vs Calendar

Could someone please advise the current "best practice" around Date and Calendar types. When writing new code, is it best to always favour Calendar over Date , or are there circumstances where Date is the more appropriate datatype? Date is a simpler class and is mainly there for backward compatibility reasons. If you need to set particular dates or do date arithmetic, use a Calenda

Java日期与日历

有人可以提供有关Date和Calendar类型的最新“最佳做法”建议。 在编写新代码时,是否最好始终支持Calendar over Date ,或者是否存在Date是更合适的数据类型的情况? 日期是一个更简单的类,主要出于向后兼容的原因。 如果您需要设置特定日期或进行日期算术,请使用日历。 日历还处理本地化。 Date的上一个日期操作函数已被弃用。 就个人而言,我倾向于在有选择时使用毫秒中的任意一个时间(或适当的长时间)或日历。 D

JVM Timezone is off by one hour

Using Java 6 update 30 on a Windows XP machine. Updating Java or Windows is not an option. I need a way to change the internal Java clock back one hour to match the system time. The machine is in Russia and Windows system time is correct, but the Java time is off by one hour, probably due to DST. I have tried changing JVM parameters as well as modifying the deployment.properties file (to ch

JVM时区已关闭一个小时

在Windows XP机器上使用Java 6更新30。 更新Java或Windows不是一种选择。 我需要一种方法将内部Java时钟改回一小时以匹配系统时间。 该机器在俄罗斯和Windows系统时间是正确的,但Java时间已经关闭了一个小时,可能是由于DST。 我尝试过更改JVM参数以及修改deployment.properties文件(更改时区),向环境/系统变量路径添加变量也无效,并尝试使用Oracle提供的时区更新工具。 前三个不会更改任何参数,并且更新程序工具崩

Convert string to appropriate date with timezone java

I am Having Date with it's timezone, I want to convert it to another Timezone, Eg I have Date '3/15/2013 3:01:53 PM' which is in TimeZone 'GMT-06:00'. I want to convert this in 'GMT-05:00' timezone. I have search lot, and I am confuse about How actually Date is working. How to Apply timezone to date. I have try with SimpleDateFormat, Calender and also with offset.

使用时区java将字符串转换为适当的日期

我有日期与它的时区,我想将其转换为另一个时区,例如我有日期'3/15/2013 3:01:53 PM'这是在TimeZone'GMT-06:00'。 我想在'GMT-05:00'时区转换。 我有很多搜索,而且我对日期实际工作方式感到困惑。 如何应用时区到日期。 我尝试使用SimpleDateFormat,日历和偏移量。 DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss aaa XXX"); df.setTimeZone(TimeZone.getTimeZone("GMT")); Date

Convert Date/Time for given Timezone

I want to convert this GMT time stamp to GMT+13: 2011-10-06 03:35:05 I have tried about 100 different combinations of DateFormat, TimeZone, Date, GregorianCalendar etc. to try to do this VERY basic task. This code does what I want for the CURRENT TIME: Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT")); DateFormat formatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z"

转换指定时区的日期/时间

我想将此GMT时间戳转换为GMT + 13: 2011-10-06 03:35:05 我尝试过大约100种不同的DateFormat,TimeZone,Date,GregorianCalendar等组合来尝试做这个非常基本的任务。 此代码完成我想要的CURRENT TIME: Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT")); DateFormat formatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z"); formatter.setTimeZone(TimeZone.getTimeZone("GMT+13"));

Timestamp deviation Java vs Javascript for old dates (3600secs)

When converting string date representation to numeric values, I obtain a different result in Java/Groovy/PHP vs in Javascript. For some dates before 1970, the JS timestamp is exactly 3600 secs before the Java timestamp. I could reproduce it for Oct 1st, but for Jan 1st it's ok. My test case (in groovy, using the usual Java API on purpose): def sdf = new SimpleDateFormat("dd/MM/yyyy") ["0

时间戳偏差Java与JavaScript的旧日期(3600secs)

将字符串日期表示形式转换为数值时,我在Java / Groovy / PHP和Javascript中获得了不同的结果。 对于1970年以前的某些日期,JS时间戳在Java时间戳之前恰好是3600秒。 我可以在10月1日复制它,但1月1日没关系。 我的测试用例(在groovy中,故意使用常用的Java API): def sdf = new SimpleDateFormat("dd/MM/yyyy") ["01/10/1956", "01/01/1956", "01/10/1978"].each { def d = sdf.parse(it) println "${it} ->

f:convertDateTime displays wrong Date if timezone is provided by a bean

While specifiing the timezone as a string literal works flawless: <h:outputText value="#{item.dateChange}"> <f:convertDateTime pattern="dd.MM.yyyy HH:mm" timeZone="Europe/Berlin"/> </h:outputText> Providing the value by bean doesn't work (Timeoffset 1h to UTC and daylight saving 1h are not applied) <h:outputText value="#{item.dateChange}"> <f:convertDateT

f:如果时区由bean提供,则convertDateTime显示错误日期

虽然将时区指定为字符串文字是完美的: <h:outputText value="#{item.dateChange}"> <f:convertDateTime pattern="dd.MM.yyyy HH:mm" timeZone="Europe/Berlin"/> </h:outputText> 按bean提供值不起作用(Timeoffset 1h到UTC和夏令时1h不适用) <h:outputText value="#{item.dateChange}"> <f:convertDateTime pattern="dd.MM.yyyy HH:mm" timeZone="#{item.platform.timeZone}"/> <