JRE Uses Wrong Timezone
Jun 26, 2015
I have a problem with timezone in my java application. My current/correct timezone is "Europe/Berlin" or CEST. When I type the following command as my user I get the correct output back:
$ date "+%Z %z"
CEST +0200
But when I run my java application it is using the timezone GMT+0100. I have executed the following Java code to verify:
import java.util.Date;
import java.util.TimeZone;
public class TimeTest {
public static void main(String args[]) {
long time = System.currentTimeMillis();
[Code] ....
When I run it the following output is generated:
Current time in milliseconds = 1435319087443 => Fri Jun 26 12:44:47 GMT+01:00 2015
Current time zone: GMT+01:00
Fri Jun 26 12:44:47 GMT+01:00 2015
So where does java get its timezone from? It's different from the default system timezone.
I am running on Redhat 6.6 with Java 1.7.0_79
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
View Replies
ADVERTISEMENT
Oct 31, 2014
<rich:column>
<f:facet name="header">
<h:outputText
value="#{msgs.viewErrorSearchCriteria_createDateTime}" />
[Code] .....
Above code is always showing date as "31-Oct-2014 10:28:57 AM GMT". I want to display this in "31-Oct-2014 10:28:57 AM EDT".
View Replies
View Related
May 2, 2014
I would like to know how to convert a time from one specific timezone to another specific timezone. The code does not convert the time correctly. But if I replace Date
date = sdfAlien.parse("16:00:00"); to Date date = new Date();
then conversion works but that's not what I want as my input will be supplied by users with time in HH:MM:SS and Java supported timezone.
In below case, we can say "16:00:00" and "Asia/Singapore" will be supplied by the user and I need to convert it to America/New_York time.
SimpleDateFormat sdfAlien = new SimpleDateFormat("HH:mm:ss");SimpleDateFormat sdfLocal = new SimpleDateFormat("HH:mm:ss");sdfAlien.setTimeZone(TimeZone.getTimeZone("Asia/Singapore"));
sdfLocal.setTimeZone(TimeZone.getTimeZone("America/New_York"));
try {Date date = sdfAlien.parse("16:00:00");String alienTime = sdfAlien.format(date);
String localTime = sdfLocal.format(date);System.out.println("Local Time:" + localTime + ", Alien Time:" + alienTime);
} catch (ParseException e) {e.printStackTrace();}
View Replies
View Related
Dec 10, 2014
In my application I need to print timezone abbreviation based on location. But fot Australia it is showing EST, even though my time zone data file version is tzdata2014i. I read that from version tzdata2014f, java supports AEST/AEDT but I don't see this in tzdata2014i.
How to get AEST/AEDT timezones.
View Replies
View Related
Dec 26, 2014
I have a requirement to convert 'unix time stamp' to 'Date time format'
Input (Unix time stamp) : 1426013480000
Output should show : 3/10/2015 2:51 PM EST (or) 10th March 2015 2:51PM EST
View Replies
View Related
Jan 25, 2015
Searching methods and sorting methods, I tried some (SelectionSort, InsertionSort, BubbleSort, SequentialSearch) and they all work, but I am having problems right now with my BinarySearch method. The problem(s) I have right now is that the method is only finding some numbers in my array, such as 1 and 8, but when I search for the other ones it only buffers and the program has to be stopped manually, since it doesn't print anything. I tried rearranging the while-loop's circumstances but that didn't work.
how to optimize my coding for future tasks so I dont get the same problem(s).
public class BinarySearch {
public static void main(String[] args) {
int[]A = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int searchedNumber = 3;
[code]....
View Replies
View Related
Oct 24, 2014
Whenever I run this I get:
There are not enough funds to do that
Balance: $0.0
Monthly Interest Rate: 0.375%
Account Start Date: Fri Oct 24 08:03:40 EDT 2014
I assumed that this is because the constructor Account(); is setting the variables to 0 every time the program runs even though I'm passing other variables through to methods and constructors. I've looked up similar programs and this is how it's done though. The steps to my homework say to create a no-arg constructor Account() that creates a default(0) account Id and balance. What did I do wrong?
import java.util.Date;
public class Account {
private int Id;
private double balance;
private double annualInterestRate;
private Date dateCreated = new Date();
public static void main (String [] args){
//Objects of Account to get non-static methods
[code]....
View Replies
View Related
May 20, 2014
I'm using apache POI to input data from a excel database. I have a method that is supposed to count the number of rows containing data so I can use that number to initialize an object array. It's returning one more than the actual number of rows and I can't figure out why.
public int getDataRange() throws IOException{
int rowCount = 0;
Iterator<Row> rows = sheet.rowIterator();
while(rows.hasNext()){
HSSFRow row = (HSSFRow) rows.next();
rowCount++;
[Code] .....
I get an array index out of bounds exception at the highlighted line.
View Replies
View Related
Sep 8, 2011
I am a novice to coding and very new to Java. It appears that I am having a similar problem as the user above "Scott Allen". With a few exceptions. My issue is that when I run the command "javac" from the command prompt I am receiving the same error:- "javac is not recognized as an internal or external command, operable program or batch file"
After reading the comments from above I have configured my System Variables "Path" and "JAVA_HOME" to match the following:
JAVA_HOME: C:Program FilesJavajdk1.6.0_21in
Path: %JAVA_HOME%in; [First Variable]
There is no "Path" User variable on my computer, although there is a "TEMP" and "TMP" in the User Environment variables.
Currently I have the following Java related software installed:
- C:Program FilesJavajre6
- C:Program FilesJavajdk1.6.0_21
- C:Program FilesSunJavaDB
- C:Program FilesEclipse-jee-galileo-3.5.2
I have confirmed the "javac.exe" is located within the in directory of Javajdk.1.6.0_21..When I send "Java -version" to the command prompt the following is returned: java version "1.6.0_26"..Immediately I noticed that the version is wrong, but don't know why or what to do. Below is the output from the command "Java" using the command prompt.
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
[code]....
View Replies
View Related
Mar 22, 2015
I've been given a school assignment that reads, "Rewrite the main class Geometry so it takes in the dimensions for the triangle and ellipse as user inputs and create a Triangle and an Ellipse class. Use the appropriate variable types, constants, variable names and computational formulas.
Triangle class will have a computePerimeter and a computeArea methods Ellipse class will have a computeArea method Create Report class
• Create a method createReport that takes the values returned from Triangle and Ellipse and combines them in the following message and displays it. Format the values so that they have 2 decimals.
“The triangle has a perimeter of [perimeter] with an area of [area] while the ellipse has an area of [area]”
• Create a method switchReport that takes the original string from createReport and changes the message to display using the available methods in the String class
“The ellipse has an area of [area] while the triangle has an area of [area] with a perimeter of [perimeter]”"
I've run into a problem when creating the createReport method. Everytime i run it i get incorrect values for the perimeter and area (namely i get zero every time).
my code is as follows:
public class Triangle
{
public double base;
public double height;
public double hypotenuse;
private double tArea;
private double perimeter;
public Triangle()
{
base = 0;
height = 0;
hypotenuse = 0;
[code]....
For the triangle class and
public class Report {
Triangle tri2 = new Triangle();
Ellipse eli2 = new Ellipse();
public Report() {
}
public void createReport() {
System.out.println("The triangle has a perimeter of "+tri2.computePerimeter() +" with an area of " +tri2.computeTArea() +" while the ellipse has an area of " +eli2.computeEArea() );
}
for the report class.the Geometry class allows you to input values and if i skip the report and simply print the perimeter and area they are correct. However with the report class it simply gives me zeros.
View Replies
View Related
Nov 6, 2014
So the idea of this program is that you enter a number, it will give out a radius ... After the radius is given then, it will ask if you want to continue yes or no, if yes then it will repeat the process. If you select no then you will be greeted with a message saying "programme complete, See you later" ...
This all works fine and the code is below... however I want to add a pop up message if someone enters an invalid Character (anything that is not a number) ...
View Replies
View Related
Apr 21, 2015
Basically I'm trying to code this program but I keep getting error can't be applied to given types. I know it has to do with my method trying to be called by an array, but I'm just kinda lost.
Write a program that prompts the user to input cash amounts and use a method to calculate the average amount for a week given 7 inputs of daily cash intake amounts for a cash register. Use an array to store the values. Recall that average is the sum of the values divided by the number of values. The method should take argument(s) of type double and return average weekly cash amount as a double.
Make sure you test your program using the test data given below and calls the averageCash() method defined above passing in the values. Verify that the input values are greater than or equal to 0. Negative numbers are not allowed. Output the values used and the averageCash value.
import java.util.*;
public class ArrayHandout {
public static void main(String args[]) {
int[] a=new int[6];
Scanner sc=new Scanner(System.in);
[Code] ....
View Replies
View Related
Aug 15, 2014
I have a problem with this application , I have a button that allows users to delete entry's from the array list, but i've noticed when i go back and click display entry's the correct entry has not been deleted.....for example if i enter a,1,2 then b,1,2, then c,1,2 in fields, then delete c,1,2 when i actually go to display the data entered a,1,2 will be gone not the one i entered.
So it seems to be deleting the entry at index 0 of the array list no matter what and not the chosen item..Delete Button Code
private void deleteBtnActionPerformed(java.awt.event.ActionEvent evt)
{
if (numTf.getText().equals("") || nameTf.getText().equals("") || yearTf.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "All fields must be full");
}
else if (count == 0)
[code]....
View Replies
View Related
Aug 28, 2014
I'm using BarChart and I've a very strange problem. Is not very simple create a test case to understand where is the problem.
In the first image is displayed a bar with the value of 2 but as you can see the y axis is not correct.
In the second image the value displayed is 4 but the y axis is completely busted.
Important thing: In my real app I change data of the chart every time the user change a combobox value (the period).
First image
Second image
This is a test case that simulate what I'm doing in my app with the only difference that data are fetched remotely with an async request in my real app.
Chart.java
public class Chart extends Application implements Initializable {
@FXML
private BarChart<String, Integer> chart;
private ObjectProperty<ObservableList<Series<String, Integer>>> seriesProperty = new SimpleObjectProperty<ObservableList<Series<String, Integer>>>();
[Code] .....
Unfortunately with this simple test case the chart display correctly data.
View Replies
View Related
Apr 10, 2015
I am trying to connect to Sql Server database using Oracle UCP with sqljdbc4-3.0 JDBC driver for Sql Server,with different ports and instances.
– the issue is with the port being ignored in the server string.
For example, using port 1440 connects to the default instance (which is on port 1433) rather than MSSQLINSTANCE1 which is on 1440.
Below are Server hosts used.
sql005.sqlasoftware.com (connects correctly to the default instance)
sql005.sqlasoftware.com:1440 (connects incorrectly to the default instance on port 1433)
sql005.sqlasoftware.comMSSQLINSTANCE1 (connects correctly to the named instance)
View Replies
View Related
Feb 5, 2015
I have generated wsdl2java code using axis 1.4 . One classes has 2 constructor methods (one default constructor and other one has 2 parameters). Other classes that inherit from one class have the constructor parameters in the wrong order. The schema files is correct as they come from the OTA specification. What should be done to get rid of this ordering problem in constructor
View Replies
View Related
Jan 9, 2014
Why is the equals-method in the super-class invoked? Shouldn't the equals-method in the sub-class be invoked(at least in the first if-statement since b2 is a B(i know B is also an A))?Is the equals-method overridden? Or does B have its own equals-method?
class SomeClass{
public static void main(String[] args) {
B b1 = new B(123,1);
B b2 = new B(123,2);
[code]...
View Replies
View Related
May 9, 2014
So all the errors in the code is fixed but its now got the wrong output
what I get:
Enter numerator; then denominator.
5
8
5/8
Enter numerator; then denominator.
4
10
4/10
Sum:0/0
it should be:
Enter numerator; then denominator.
5
8
5/8
Enter numerator; then denominator.
4
10
4/10
Sum: 82/80 1.025
Product: 20/80 0.25
Enter numerator; then denominator.
6 0
infinity
here is the code
Fraction.java
public class Fraction { //declares that it's a class that can be intantiated
private int numer; // private intager for numerator
private int denom; // private intager for denominator
[Code] ....
View Replies
View Related
May 7, 2014
I am developing a JavaFX application under Java 8 on my Ubuntu 14.04 (32 bit) system. When I run it on the Ubuntu box, all is fine, but when I run it under Windows 7 Home Premium (64 bit) with the same Java8 release installed, all my buttons have their text ellipsised (sp?). Why the behavior is different? Or is this a bug in JavaFX? Here are the particulars:
fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?><?import java.util.*?><?import javafx.geometry.*?><?import javafx.scene.*?><?import javafx.scene.control.*?><?import javafx.scene.layout.*?><?import javafx.scene.text.*?>
<AnchorPane id="AnchorPane" prefHeight="91.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml">
[Code] ....
Java:
java version "1.8.0_05"Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)
View Replies
View Related
Nov 27, 2014
I have a bookings table where customers can view their bookings and in the table there is a button with a command button that onclick goes to the dialogue to display the variable petUpdate value but if you have 2 bookings then all the update buttons display the value of the last petUpdate in the arrayList.
DataTable with the button
<p:dataTable
id="bookingTable"
var="customerBooking"
value="#{booking.sessionBookingList}"
editable="true"
style="margin:0px 0px 20px 100px;font-size:15px;width:600px;"
>
Code in the above datatable.......The commented out output label displays the correct value for each but when the button is clicked the dialog only displays the last ones value
<p:column headerText="Check Updates" style ="width:50px;">
<!-- <h:outputLabel value="#{customerBooking.petUpdate}"></h:outputLabel> -->
<p:dialog header="#{customerBooking.petName}'s Status" widgetVar="dlg1" minHeight="60" minWidth="60" maxWidth="60">
<h:outputText value="#{customerBooking.getPetUpdate()}" />
</p:dialog>
<p:commandButton value="?" onclick="PF('dlg1').show();" style ="width:40px;">
</p:commandButton>
</p:column>
View Replies
View Related
Feb 11, 2015
My program is reading my file, but its printing out weird cryptic numbers instead of the 1-10 that is in the file. But it uses the numbers in the file to get the Max Value and Total. Also I am receiving 0 for my Minimum Value but, 0 isn't even in the file, my lowest value is 1.
Java Code: /*
* Student Name: Irrelavent
*
* Description: This program will read from a text file and display its contents in an array format as well as the average of the numbers and the minimum and maximum value within the array and it will display the total of all the numbers added together.
*
* Input Variables:
*
* Desired Output:
* Total: 55
Average: 5.5
Minimum Value: 1.0
Maximum Value: 10.0
The data being used is: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
*/
[Code] ....
Output:
Numbers being used: [[I@55f96302]
---------------
Max Value: 10
---------------
Minimum Value: 0
---------------
Average: 0.0
---------------
Total: 55
I want 1 for my Minimum and I want 5.5 for my average, when I make 'average = total / numbers.length;' ---> 'average = total / (double)numbers.length;' I get 0.55. Also, as its obvious, my 'Numbers being used' section is messed up and I don't know whats causing this.
View Replies
View Related
Dec 31, 2013
We use a Java program to read an XML file and put its content into a database. We also use Date() to get the current date and insert it into a field in database with content from XML file. Everything worked flawlessly until today, the last day of 2013. We are getting 2014 for the year instead of 2013!!! System date shows correct year, so this must not be an issue.
View Replies
View Related
Feb 24, 2015
the below program is to read the time intervals (HH:MM) and to compare system time if the system time between your time intervals print correct time and exit else try again to repeat the same thing. By using StringToknizer class. and i have written like this
import java.io.*;
import java.util.*;
public class Main
{
static int k1,k2,v1,v2;
public static void main(String args[]) throws IOException
{
DataInputStream o=new DataInputStream(System.in);
[Code] ....
but is showing correct for some inputs and wrong for some inputs ....
View Replies
View Related
Sep 1, 2014
The problem occurs after the user inputs the guess.... it either runs the for loop if guess = numtoguess and reveals the answer even if the user input is wrong.... or it always runs the first if statement in the while loop if guess!= to numtoguess... heres the code
public static void main(String[] args) {
String[] Answers = {"yes", "Yes", "No", "no"};
String Name = JOptionPane.showInputDialog(null, "Hello, What is your name?","Random Game", JOptionPane.QUESTION_MESSAGE);
String UI = JOptionPane.showInputDialog(null, Name + " do you want to play a game", "Random Game", JOptionPane.QUESTION_MESSAGE);
[Code] ....
View Replies
View Related
Feb 28, 2014
I think I fixed the first error, but now I'm receiving another error in my Net Pay print statement at the end.
Here is what I'm supposed to receive:
Net Pay: 599.86
Here is my sample run:
run-single:
Enter hourly rate in dollars and cents --> 27.16
Enter number of hours and tenths worked --> 37.9
PAYROLL REPORT
Rate: 27.16
Hours: 37.9
Gross Pay: 1029.36
Federal Tax: 257.34
State Tax: 93.41
FICA: 78.75
Net Pay: 771.86
Employer's FICA contribution: 78.75
Employer's UEI and DI contribution: 20.59
Cost to Employer: 1128.70
Enter hourly rate in dollars and cents -->
Here is my updated code:
package assignmentproject1;
/* CHANGE (FINAL) VAR NAMES, SCAN & VERIFY,
ORGANIZE AND PUT FORMULAS ON BOTTOM, ORGANIZE VAR @ TOP, */
import java.util.*;
public class Project1 {
public static void main (String[] args)
[Code] ....
View Replies
View Related
Aug 1, 2014
My form looks like this:
<h:form>
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<p:outputLabel for="filetype" value="FileType: " />
<p:selectOneRadio valueChangeListener="#{selectView.changeServerAndSignmethod}" onchange="submit()" id="filetype" value="#{selectView.filetype}">
<f:selectItems value="#{selectView.filetypes}" itemLabel="#{filetype}" itemValue="#{filetype}" />
</p:selectOneRadio>
<p:outputLabel for="signmethod" value="Sign Method: " />
<p:selectOneMenu valueChangeListener="#{selectView.changeServers}" onchange="submit()" id="signmethod" value="#{selectView.signmethod}">
<f:selectItems value="#{selectView.signmethods}" itemLabel="#{signmethod}" itemValue="#{signmethod}" />
[code]....
As you can see there are two listener in my xhtml file one for filetype and other for signmethod. When filtype changes signmethod has to change which in turn changes servers. And if user changes signmethod using dropdown then also server should change. But my problem is when filetype changes, both the listeners are called, as signmethod also changea but the value in event object (e.getNewValue()) is not the new one but old one. Here is the SelectView Bean.This is the static initialisation part just for checking the output at the end of question.
static {
initFiletypes.add("Windows");
initFiletypes.add("Mobile");
initFiletypes.add("Mac");
initFiletypes.add("Solaris");
initFiletypes.add("Jar");
windowsSignmethods.add("Microsoft");
windowsSignmethods.add("Driver");
windowsSignmethods.add("Driver_Pagehash");
windowsSignmethods.add("HDR");
windowsSignmethods.add("Java2");
windowsSignmethods.add("Javame");
windowsSignmethods.add("MicrosftApps");
[code]....
I am changing servers in changeServerAndSignmethod by selecting first signmethod from signmethod arraylist which is giving correct result. But changeServers is also getting fired taking wrong event object's newValue method and changing servers to wrong values. When changeServers is fired bydirectly changing signmethod, by dropdown, it gives correct result. Is there a way I can stop changeServers to fire when the change came from changing filetypes rather than direct change by user on signmethod selectOneMenu.
View Replies
View Related