I have two Java instances of java.util.Date and I have to find out if they refer to the same day.
I can do this the hard way, taking the dates apart and compare the days, making sure the years match too.
Since this is such a common problem, I expect there to be an easier solution to this problem.
Thanks!
...
I want to change modification timestamp of a binary file. What is the best way for doing this?
Would opening and closing the file be a good option? (I require a solution where the modification of the timestamp will be changed on every platform and JVM).
...
public class Ex7 {
private int fld;
private void meth(int val) {
fld = val;
System.out.println(" meth() -> fld = " + fld);
}
public class Ex7Inner1 {
void operateOnFld() {
fld = 12;
}
void operateOnMeth() {
meth(10);
}
public void bar() {
...
Is message passing taking place when calling a function with no input?
i.e. with: object.toString();
Am I passing a message to 'object'?
This might vary between languages, but I'm specifically referring to Java.
...
I have the following snippet of code:
String path = servletContext.getRealPath("/");
Now I got a bugreport from a user saying that the returned path is not an absolute path.
The returned path is 'usr/local/...' instead of '/usr/local/...' , so getRealPath seems to be returning a relative path.
I can see this, because the returned pat...
Consider this case:
public Class1 {
public static final String ONE = "ABC";
public static final String TWO = "DEF";
}
public Class2 {
public void someMethod() {
System.out.println(Class1.ONE + Class1.TWO);
}
}
Typically you would expect the compiler to inline the ONE and TWO constants. However, is this behavior guarant...
I am having an issue with this error:
**Server returned HTTP response code: 501 for URL: http://dev1:8080/data/xml/01423_01.xml**
See this code:
private static Map sendRequest(String hostName, String serviceName) throws Exception {
Map assets = null;
HttpURLConnection connection = null;
Authenticator.se...
I have logged in to a website by using WATIJ jar file in java. Now I want to get the page source (HTML code) of the webpage that appeared after login.
I have IE instance already.
...
I was trying to create a mouse clicked event of a JmenuItem but it did not work but mouse pressed event works. what is the difference between clicked and pressed and why only pressed works here?
...
I have a situation where a servlet is providing compressed data to a PHP script. I compress the data on the Java side no problem, but PHP seems unable to decompress.
Here is the relevent code snippets
Java Side:
OutputStream o=response.getOutputStream();
GZIPOutputStream gz=new GZIPOutputStream(o);
gz.write(GridCoder.encode(rs,id...
I am instantiating a log4j object inside of a class which inherits most of the methods and attributes from a parent class. Right now I'm getting logging messages from the subclass only. How can I get logging messages to output in both the super class and subclass?
EDIT: The way I am do the logging is that I have an instance variable i...
Where is the source code for /jre/lib/deploy.jar?
I have the source code for other jars like rt.jar (in /src.zip) but not deploy.jar.
I need it to debug webstart.
I'm using 1.6 on Windows if that makes a difference.
...
I came across a comment in some java code that states that getTime() needs to be called to update the Calendar object. Is this true? I cannot find anything that says that this is necessary.
Here's the code:
Calendar cal = new GregorianCalendar();
cal.setFirstDayOfWeek(Calendar.SUNDAY);
cal.set(2009, 9 - 1, 10, 2, 30);
// Get Time needs...
Hi everyone!!
My new project is to build an application to use the cell phone camera as the main camera from my PC.
How can I do this kind of stuff?
I thought of using bluetooth, but how my PC define the cell phone as the main camera?
Best reguards.
...
Using Dozer to map two objects, I have:
/**
/* This first class uses the GXT (ExtJS) framework
**/
Class1 extends BaseModelData
{
public int getId()
{
return (Integer)get("id");
}
public void setId(int id)
{
set("id", id);
}
// more properties
}
Class2
{
public int getId()
{
return i...
Hello, I am trying to use a RequestDispatcher to send parameters from a servlet.
Here is my servlet code:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String station = request.getParameter("station");
String insDate = request.getParameter("insDate");
...
I'm trying to parse and load an XML document, however I'm getting this exception when I call the parse method on the class that extends XmlObject. Unfortunately, it gives me no ideas of what element is unexpected, which is my problem.
I am not able to share the code for this, but I can try to provide more information if necessary.
...
Say i have a java project setup in eclipse. i have all the thirdparty jar's and reading the resources etc set in the eclipse IDE.
ie all the classpath etc are set through the IDE
Now if i want to launch my app from commandline.
Can i get some hints/ links where i can undersand the configuration settings that can be done in Unix / windo...
I need a component/class that throttles execution of some method to maximum M calls in N seconds (or ms or nanos, does not matter).
In other words I need to make sure that my method is executed no more than M times in a sliding window of N seconds.
If you don't know existing class feel free to post your solutions/ideas how you would im...
How to suspend current thread for 20 seconds in java?
...