Get Current Utc Date / Time?

Jun 2, 2014

I am trying to get the current utc date/time, but it keeps printing out in local time:

Java Code: LocalDateTime dt = LocalDateTime.now();
ZonedDateTime zdt = dt.atZone(ZoneOffset.UTC);
System.out.println("time: " + zdt);
// output:
time: 2014-06-02T13:37:55.705Z mh_sh_highlight_all('java');
13:37 is local time. Utc time is 17:37.

View Replies


ADVERTISEMENT

Current Date And Time To A String?

Mar 18, 2014

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;
public class Swipe_In {
public String DTStart; //Swipe in Date Time

[code]....

I have got 2 questions on the above class...

1) I get an error "Cannot make a static reference to the non-static field DTStart" wherever i use DTStart in the main method....What's causing this error? and How do i fix it for good?

2) public String DTStart; Once i get the current date & time assigned to the above DTStart String in the main method i cannot use the updated value of DTStart in any other class. In another class i wanna create an instance(object) of this Swipe_In class with DTStart assigned to the current time(as in its main method)..I tried but the object's DTStart gets assigned to null.(( How do i achieve this?

View Replies View Related

Assign Current Null Value To Current Date?

Mar 6, 2014

How can i assign current  null value to current date, I only what to assign this if the current value coming from database is null otherwise i must use value from database

public static String getDate(Calendar cal){
        return "" + cal.get(Calendar.DATE) +"/" +
                (cal.get(Calendar.MONTH)+1) + "/" + cal.get(Calendar.YEAR);
    }
try {

[Code] .....

View Replies View Related

Algorithm That Asks User For Birth Date And Current Date

Sep 29, 2014

write the algorithms of the following problems.

1. Write an algorithm that asks the user for your birth date and the current date and displays how many days has passed since then (remember that April, June, September and November has 30 days, February has 29 on leap years, and the rest 31)

2. Write an algorithm that asks the user a number (save it as N) and displays the N term of the Fibonnacci series (take it as 1, 1, 2, 3, 5 ...)

View Replies View Related

Splitting Date String By Date And Time And Assigning It To 2 Variables?

Jul 17, 2014

I have an requirement of splitting a Date-Time String i.e. 2013/07/26 07:05:36 As you observe the above string has Date and Time with space in between them.

Now I want just want split the string not by delimiter but by length i.e. after 10th place and then assign it to 2 variable i.e. Date <----2013/07/26 and Time <---07:05:36 separately.

View Replies View Related

Print Current Time Every Second?

Nov 13, 2014

I need to write a program that prints the current time every second. Here is what I have and I am not entirely sure why I'm not.

Java Code:

import java.util.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
public class CurrentTime

[Code] .....

View Replies View Related

Writing Current Time To Text File

May 29, 2014

I'm working on a project for class that asks me to record punch-in and punch-out times for employees. However, I am having difficulty figuring out where I am going wrong as none of the information will write to the text file in the ArrayList that I have created. The code is as follows:

import java.text.*;
import java.util.*;
import java.io.*;
import java.nio.file.*;
public class TimeClockApp {
// declare class variables
private static EmployeeDAO employeeDAO = null;

[Code] .....

I want to keep the coding as simple as possible as I am new to Java, and have spent hours upon hours trying to figure this all out. The console output looks like this:

Welcome to the Punch-In/Punch-Out Screen

Please choose an option below:

I. Punch In
O. Punch Out
Choice: i

PUNCH IN
--------
Enter Employee ID:
8
8Punch-In Date & Time: 2014/05/28 22:44:26
[]
Press enter to return to the main screen:

View Replies View Related

Make Date Column Show Only Date And TimeIn And TimeOut Column Only Show Time

Mar 11, 2014

How do i make the 'date' column show only the date and 'timeIn' and 'timeOut' column only show the time. In my database table my 'date' column is a date type and 'timeIn' and 'timeOut' column is time.

View Replies View Related

How To Use Logger And Prints Time And Date

Feb 5, 2015

I need to add Logger function in the catch block that prints time, date and description of the what had happened.

public class InputUtil {
public static final String[] SPECIAL_CHARACTERS = { "!", "#","%", "^", "=",
"+", ";", "[", "]", "|", "<", ">", "?", "~", "`", "-", "" };
public static String deleteSpecialCharacters(String inputString) {
String outputString = inputString;

[Code] ....

View Replies View Related

JSP :: Using JSTL To Format Date And Time

Jul 14, 2014

How to format this "2014-07-14T19:40:46" date to dd-mm-yyyy with time using jstl?

View Replies View Related

Converting String To Date And Time MYSQL

Apr 8, 2014

In my java file I made Strings of date and time, but my MYSQL database needs Date and Time of course. I've tried to convert them, but I keep getting this exception: org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: "2013-02-20"

public class Vogel {
static final String url = "jdbc:mysql://localhost:3306/turving";
public static void Insert(String datum, String tijd, String plaats, String spotternaam, String vogelsoort) {
try {
SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-DD");
SimpleDateFormat formatt = new SimpleDateFormat("HH:MM:SS");
java.util.Date parsed = format.parse(datum);
java.util.Date parsedd = formatt.parse(tijd);
java.sql.Date sql = new java.sql.Date(parsed.getTime());
java.sql.Time sqll = new java.sql.Time(parsed.getTime());

[code]....

View Replies View Related

Current Execution Time Of A Class In Java By Running Another Class

Jul 14, 2014

i want to write a class in such a way that i should get the current execution time of another class which is running. I searched in net but it shows only how to calculate the time duration of the current class which is running. But as per my way, i need the execution time of one class from another class. How to do this ?

View Replies View Related

JavaFX 2.0 :: DateTimePicker - Option To Choose Date And Time?

Jun 6, 2014

JavaFX 8 has a DatePicker which is very nice. Does it have an option to chose a date and a time?

View Replies View Related

Unix Timestamp Conversion To EST Timezone Date Time Format

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

How To Create JavaScript To Find Current Month And Current Day Of Month

Mar 17, 2015

I want to be able to use the current date to solve a math problem, specifically as follows:If today is March 17, the math problem of the day should be:

(Month times Day of Month) + 99 = Answer of the Day

(3 x 17) + 99 = 150

How can I create a java script to find the current month and the current day of month, multiple those two together, then add 99 and display the answer as a result.

View Replies View Related

How To Check For Todays Date When Writing Own Date Class

Dec 3, 2014

I am trying to write a date class and not use the built-in library. How do I check for today's date?

View Replies View Related

Transform Simple Date Format - Get Calendar Date

Apr 4, 2015

Given a Date such as this sampleDate (120, 08, 02), does SimpleDateFormat transform this given sampleDate using (sampleDate.get(Calendar.DATE)) ?

Issue is that without the SimpleDateFormat the days are outputting correctly but starting with 1,2,3,4 etc and when I apply the SimpleDateFormat to the above Date I only get 01,01,01 etc...

I am looking for 01,02,03 etc...

View Replies View Related

How To Use Date Mask For Date Column In JTable

Jan 23, 2015

inserting a date mask for the column Date in jtable when the user edits the value in the row,the mask should be shown in column Date.

View Replies View Related

Military Time - Adding Minutes Displaying Correct Time

Feb 9, 2015

I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)

I need the output time to be the time the class started, plus the length of the class, and displayed in military time.

for example,

Start Time = 0930
Length = 50 minutes
Endtime = 1020

I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say

Start time: 0700
Length = 90 minutes

I get:

Endtime = 90

90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.

Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.

public class calc
{
public static void main(String[] args) {
double hours, minutes, length;
double temp;
int time = 2400;
hours = time / 100;
System.out.println("Hours are: " + hours);

[Code] ....

View Replies View Related

Converting Military Time To Standard Time?

Jan 29, 2014

I have two classes. time_runner is used for testing my code.

This is what I'm using to test my code:
 
class time_runner
{
 public static void main(String str[]) throws IOException {
 Time time1 = new Time(14, 56);
System.out.println("time1: " + time1);
System.out.println("convert time1 to standard time: " + time1.convert());
System.out.println("time1: " + time1);
System.out.print("increment time1 five times: ");
time1.increment();

[code]....

The two constructors are "Time()", which is the default constructor that sets the time to 1200, and "Time(int h, int m)" Which says If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0. Those are my two constructors that I pretty much have down. The three methods however I'm having trouble with. The "String toString()" Returns the time as a String of length 4. The "String convert()" Returns the time as a String converted from military time to standard time. The "void increment()" Advances the time by one minute.

public class Time {
private int hour;
private int minute;
  public Time(int h, int m) {
if(h > 1 && h < 23)
hour = h;

[code]....

View Replies View Related

How To Find The Current Path Of A File

Jun 24, 2014

First of all, i am using ubuntu and jdk8. My problem: displaying the current path of a file in my system Approach: I have a file called dummy.txt in a given directory which have enough permissions and i did the following:

File file=new File("dummy.txt");
System.out.println(file.getAbsolutePath().substring(0,file.getAbsolutePath().lastIndexOf("/")));

I expected to see displayed the current path of the file without the name of the file but it is showing a different path. I just want to display the current path of the file without the name.

View Replies View Related

Swing/AWT/SWT :: How To Close The Current Jframe

Sep 14, 2014

Following is the code on the click of a button, id like to know how do i close the current jframe on which the jButton4 is currently placed. I know how to send it to the next Jframe i.e JobCard. But need to close the current one. I tried using this.setVisible(true); But it does not work.

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
JobCard jobCard = new JobCard();
jobCard.setVisible(true);
}

View Replies View Related

Memory Calculator - How To Keep Track Of Current Value

Nov 10, 2014

Basically we have to create a calculator that it will have to keep track of the current value, and do the functions that the calculator uses.

But I have it working for the most part, but the current value does not keep...

The double " currentValue " Must stay private.

import java.util.*;
 public class MemoryCaluclator {
 private double currentValue;
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int answer = 0;

[Code] ......

View Replies View Related

Set Class Path For One Level Down The Current Directory?

Jun 29, 2014

Can we set the class path for one level down the current directory? My structure is like

binlibresourceshexicon.cmdinside the folder dist.

In this case I could run the .cmd file which has java -cp .;lib;resources client.Test .

c: rycpdist>java hexicon.cmdBut if i put the .cmd file inside bin as like this and run as
c: rycpdistin>java hexicon.cmdI am getting this error Error: Could not find or load main class

Is there any possibility to set the class path in this case

View Replies View Related

Measure Current Download Speed Of File?

Jan 5, 2014

Is there a way to measure current download speed of a file being downloaded? I've searched all over google and the only thing i get is average download speed. This is basically how it is being done, the result is average download speed.

Java Code:

OutputStream out = null;
URLConnection conn;
InputStream in = null;
long startup = System.currentTimeMillis();
try {
URL url = new URL(adress);
out = new BufferedOutputStream(

[Code] .....

View Replies View Related

Current Options For Applet To Servlet Communication

Feb 12, 2014

My primary question is about which method is the best for having an applet of mine communication with a backend database of mine. In other words, I don't want to try learning a technology that is out of date or not a good fit for my goal. I purchased the O'Reilly title "Java Servlet Programming", but it seems to be very old and out of date (referencing Netscape 4, etc.) and I see a Java RMI O'Reilly title on Amazon, but it was written in 2001.

My basic goal is to allow my applet to have access to a back-end database for reading and writing. I understand that direct Applet to DB (via JDBC) access is a bad idea so my thought is to create a servlet (much like web service for lack of a better term) or an actual web service (RESTful would be my first guess) to broker the requests. I already have a very basic servlet running that has access to my database server so now I want to focus on the best method for making calls from the applet to the servlet but having said that I don't want to go down this road too far if a servlet is not the right tool for the job.

My reading has been leading me to RMI, but as I said, I don't want to focus on that if there is a better option. In a non-Java environment, I'd use a web service (REST, SOAP, etc.) and perhaps that's what I should do here as well and not even bother with a servlet per se and just go with a web service.I know there can be some subjectivity with regard to these choices and I don't need to know what the "best" one is.I don't want to use RMI if it's dead or has been surpassed by something else, for example.

Should I use a servlet? Should I use a web service? My needs are rather modest; query the database, send updates to the database, etc. Nothing too crazy.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved