Hi Folks,
I have a Java Date object containing date and time information, e.g. 2008-01-01 13:15:00. I want to write a method that cuts off the time information so I only have the date left, e.g. 2008-01-01 00:00:00.
Do you have a tip? I tried doing something like this
(timestamp / (24 * 60 * 60 * 1000)) * (24 * 60 * 60 * 1000)
but I ...
Is there a way to determine if an instance of a org.apache.poi.hwpf.model.ListData belongs to a numbered list or bulleted list?
I am using Apache Poi's org.apache.poi.hwpf.HWPFDocument class to read the contents of a word document in order to generate HTML. I can identify the list items in the document by checking to see that the paragr...
I'm new to threads. How can I get t.join to work, whereby the thread calling it waits until t is done executing?
This code would just freeze the program, because the thread is waiting for itself to die, right?
public static void main(String[] args) throws InterruptedException {
Thread t0 = new Thready();
t0.start();
}
@Override
pu...
Hi,
I get the following error
12-15 16:54:37.125: ERROR/MediaPlayer(6032): error (-2147483648, 0)
when trying to execute this code in a service:
MediaPlayer mp = null;
@Override
public void onCreate() {
if (mp == null) {
mp = new MediaPlayer();
}
}
@Override
public void onStart(Intent intent, int startId) {
if (!mp.isPlayi...
Having searched for books for learning Java here on StackOverflow, I decided to pick up a copy of Head First Java from a local library. Sadly, only the first edition from 2005 is available (the second edition came out only this year). I never did any Java before, so excuse me if the question is silly, but is the first edition of the book...
Hi everyone,
I'll try to explain my problem. I use the JSF 1.2 implementation of IBM in a very very rigid environment (company layer, and strict constraints -don't add library etc.-).
I want to create a simple page for confirmation that can be reused (kind of generic).
For example :
1-page1.jsp > click on button
2-pageConfirmation.jsp ...
I'm using JDBC in sync with MySQL to add and define rows to a MySQL database's Table. The problem is that I don't know why it is throwing an Exception when I use methods from the ResultSet class to add rows to the table. Bear in mind that I've earlier tried just reading the table via ResultSet methods, and, it successfully printed out th...
I use prepareStatement() when the id is a key of my SQL table and it will be created by SQL and I want to use this statement :(what should I write instead of X in the first column of SQL table(reminder:SQL create it automatically)
File file = new File(pathFile);
FileInputStream input = new FileInputStream(file);
...
Recently, I try to internationalize an application to Chinese speaking country.
I realize there are wide variety of encoding methods for Chinese character : Guobiao, Big5, Unicode, HZ
Whenever user input some text, my Java application need to know what kind of input encoding method the users are using, in order for my Java application ...
I wish to store UUIDs created using java.util.UUID in a HSQLDB database.
The obvious option is to simply store them as strings (in the code they will probably just be treated as such), i.e. varchar(36).
What other options should I consider for this, considering issues such as database size and query speed (neither of which are a huge c...
Given a class (ex: foo.bar.MyClass), how can I get a count of the number of instances of that class existing within the JVM?
Thanks
EDIT: I'm looking for the code that will retrieve this count.
EDIT: More specifically, an implementation of the method Integer getInstanceCount(Class c)
...
Hi all,
I am currently studying at university and based on other peoples recommendations I am beginnning to read other peoples code.
i have found and downloaded the source for an open source java project, that seems quite interesting. I want to load this project into an IDE (netbeans or eclipse), so as to make it easier to read and ...
I've recently started learning the Spring Framework, and I'm a bit unclear on how the ApplicationContext is supposed to be used - in both standalone and web applications. I understand that the ApplicationContext, once instantiated with the spring configuration xml, is the "spring container" and is a singleton.
But:
In the starting po...
Sorry for dummy question, but i lost my whole day to start with JasperReport. The problem is that i always receive this exception: "org.xml.sax.SAXParseException: Premature end of file." when i am trying to read .jrxml file. It is not possible to not to be well-formed, because its generated with iReport.
I asked in jasper forums, but n...
Hi all, I've got a problem with generic classes in java.
I've got this class:
public abstract class MyMotherClass<C extends AbstractItem>
{
private C item;
public void setItem(C item)
{
this.item = item;
}
public C getItem()
{
return item;
}
}
An implementation of this class can be:
public...
I am developing a program that I want to share with certain people, however if I change my mind about these people I want to be able to 'revoke' their access to the program.
Ideally this would be on a per-user basis rather than just blocking all instances of the program. Something along the lines of user accounts, but at the moment I ...
In Php I really often use this one:
$conn_sets = array();
$conn_sets['login'] = "aaa";
$conn_sets['pass'] = "bbb";
How to do the same in JAVA 1.6.
I tried to do this:
private method1() {
String[] mystring = new String[] {"login" => "aaa", "pass" => "bbb"};
}
But it give's me an error.
I want to make this work, because I hav...
If I were to define some function in the database (perhaps Postgres, or any other database):
create or replace function isValidCookie(ckie);
I would call it from SQL as:
select * from cookietable c where isValidCookie(c.cookie);
How can I call a custom function such as this from Hibernate?
...
Has anyone ever persisted a training set for CI-Bayes? I have sample code from this site: http://www.theserverside.com/news/thread.tss?thread%5Fid=49773
here is the code:
FisherClassifier fc=new FisherClassifierImpl();
fc.train("The quick brown fox jumps over the lazy dog's tail","good");
fc.train("Make money fast!", "bad");
String c...
I use Jung to draw graphs. Below is a simple graph with tree layout that looks fine. All renderers and transformers are default.
Now, I have changed the default size of the nodes to 100px by setting a custom VertexShapeTransformer. The problem is that the nodes started to overlap. Here you can see how it looks:
Is it possible to g...