Long.MAX_VALUE - System.currentTimeMillis()


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Long.MAX_VALUE - System.currentTimeMillis()
# 1  
Old 03-17-2014
Debian Long.MAX_VALUE - System.currentTimeMillis()

How can i get Long.MAX_VALUE - System.currentTimeMillis() ( in Java ) In Unix.

date %s is not the timpstamp in millis.

Also is it possible if we can System.currentTimeMillis() equivalent of
yesterday's 23:59:59 in millis ?
# 2  
Old 03-17-2014
What version of unix are you running this on?

Is date +%s.%N supported?

Some unix versions allow date +%s%-03N and echo $(( $(date -d "0:0" +%s) - 1 ))999


If you have perl you could also try:

Code:
perl -le 'use Time::HiRes gettimeofday; ($s,$m)=gettimeofday; printf "%d%03d\n",$s,$m/1000'

and
Code:
perl -le '@t=localtime();print time - $t[2] *3600 - $t[1]*60 - $t[0] - 1,"999\n"'


Last edited by Chubler_XL; 03-17-2014 at 11:56 PM..
# 3  
Old 03-18-2014
%N gives in NANO second , not in millis.
also how can i get yesterday's date and time in millis
# 4  
Old 03-18-2014
Nano -> Milisecond is just a matter of rounding. 2nd part of each example is yesterday's ms value. Please try my solution.

Last edited by Chubler_XL; 03-18-2014 at 06:30 AM..
# 5  
Old 03-18-2014
Quote:
Originally Posted by mohapatra
also how can i get yesterday's date and time in millis
Again, what is your system? Methods for date math can vary wildly from system to system.
# 6  
Old 03-18-2014
Bash shell. It shoudlnt depend on the flavour of unix.
# 7  
Old 03-20-2014
Quote:
Originally Posted by mohapatra
Bash shell. It shoudlnt depend on the flavour of unix.
Unfortunately it does. About the only portable way to do date math in UNIX is perl -- and standard Perl routines don't have millisecond accuracy.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Migrating jobs from COBOL Mainframe system to UNIX system

In a nutshell requirement is to migrate the system from mainframe environment to UNIX environment (MF cobol would be used I guess). I have not much of idea in this field. I need to do some investigation on following points - - Ease of conversion - Known Data compatibility issue - Issue in... (9 Replies)
Discussion started by: Tjsureboy4me
9 Replies

2. AIX

Cloning a system via mksysb backup from one system and restore to new system

Hello All, I am trying to clone an entire AIX virtual machine to a new virtual machine including all partitions and OS.Can anyone help me on the procedure to follow? I am not really sure on how it can be done.Thanks in advance. Please use CODE tags for sample input, sample output, and for code... (4 Replies)
Discussion started by: gull05
4 Replies

3. Programming

Problems with JNI and currentTimeMillis function

Hello, I have a technical problem: I work on AIX 7.1 with Java 1.7 (32 and 64 bit) and I make an application that intercepts certain functions related to time. In this application there is a Java JNI agent with whom I can intercept the Java "getLastModifiedTime" no problem but I am unable to... (5 Replies)
Discussion started by: steph311
5 Replies

4. Solaris

How to find out bottleneck if system is taking long time in gzip

Dear All, OS = Solaris 5.10 Hardware Sun Fire T2000 with 1 Ghz quode core We have oracle application 11i with 10g database. When ever i am trying to take cold backup of database with 55GB size its taking long time to finish. As the application is down nobody is using the server at all... (8 Replies)
Discussion started by: yoojamu
8 Replies

5. Solaris

uptime command not showing how long the system has been up

Hello folks, uptime command not shows how long the system has been up. I know it come from a corruption of /var/adm/utmpx file. I've done : cat /dev/null > /var/adm/utmpx Now who and last commands work fine. But uptime still give me back an answer without the "up time". In which... (6 Replies)
Discussion started by: gogol_bordello
6 Replies

6. UNIX for Advanced & Expert Users

how to make a full system backup excluding data and restoring it to a new system

Hi, In order to have a sand box machine that I could use to test some system changes before going to production state, I'd like to duplicate a working system to a virtual one. Ideally, I'd like to manage to do it this way : - Make a full system backup excluding the user file system (this... (7 Replies)
Discussion started by: pagaille
7 Replies

7. Shell Programming and Scripting

determine the active processes on the system which are running since long time

Hi , Please help me shell script to determine the active processes on the system which are running since long time (2 Replies)
Discussion started by: itian2010
2 Replies

8. SCO

file system not getting mounted in read write mode after system power failure

After System power get failed File system is not getting mounted in read- write mode (1 Reply)
Discussion started by: gtkpmbpl
1 Replies

9. Solaris

rsh commands not getting executed from Solaris 10 System to AIX System

Hi Friends, I am trying to execute rsh commands from Solaris 10 system to AIX system. When I give; Solaris10# rsh <hostname> ls -l , it gives me an error rshd : 0826-826 The host name for your address is not known At the same time, Solaris10# rsh <hostname> ---- gives me remote shell of... (25 Replies)
Discussion started by: jumadhiya
25 Replies
Login or Register to Ask a Question