java conversion

java conversion

how do i convert String date="Aug 31, 2012 19:23:17.907339000 IST" to long value

View Answers

October 31, 2012 at 11:32 AM

Here is a code that converts string date to long.

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ConvertStringDateToLong {
  public static void main(String[] args) throws Exception {
    String today = "Aug 31, 2012 19:23:17.907339000 IST";

    DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss.S z");
    Date date = formatter.parse(today);
    long dateInLong = date.getTime();

    System.out.println("date = " + date);
    System.out.println("dateInLong = " + dateInLong);
  }
}

October 31, 2012 at 7:17 PM

Thank you for your post. The output dateInLong gives millisecond but i want nanosecond long value for the exact date "Aug 31, 2012 19:23:17.907339000 IST" how can i do..?

Ads









Related Tutorials/Questions & Answers:
java conversion
java conversion  how do i convert String date="Aug 31, 2012 19:23:17.907339000 IST" to long value
form to java script conversion
form to java script conversion  I am using a form one more form cotain a piece of code . how to convert it to java script to function it properly..." name="ie" value="UTF-8" /> <input type="text" name="q" size="55" />
Advertisements
image conversion tools
image conversion tools  how many tools are available in image conversion at particularlly in java
Java Date Conversion
Java Date Conversion In java date conversion, two packages are used... seconds and even then only Java provides implementation that actually track leap... Java Converts String into Date In this example we are going to convert
conversion Applet
conversion Applet  I am a java beginner.................. strong texthow to create JApplet that prompts the user to enter a distance in miles in a JTextField and then converts mile to kilometers and display the result as XX.XX
Maven dependency for cn.featherfly - featherfly-conversion version 1.4.0 is released. Learn to use featherfly-conversion version 1.4.0 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.4.0 in Java... and includes  cn.featherfly - featherfly-conversion version 1.4.0 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.2.0 is released. Learn to use featherfly-conversion version 1.2.0 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.2.0 in Java... and includes  cn.featherfly - featherfly-conversion version 1.2.0 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.2.1 is released. Learn to use featherfly-conversion version 1.2.1 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.2.1 in Java... and includes  cn.featherfly - featherfly-conversion version 1.2.1 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.3.0 is released. Learn to use featherfly-conversion version 1.3.0 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.3.0 in Java... and includes  cn.featherfly - featherfly-conversion version 1.3.0 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.3.1 is released. Learn to use featherfly-conversion version 1.3.1 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.3.1 in Java... and includes  cn.featherfly - featherfly-conversion version 1.3.1 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.3.3 is released. Learn to use featherfly-conversion version 1.3.3 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.3.3 in Java... and includes  cn.featherfly - featherfly-conversion version 1.3.3 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.3.4 is released. Learn to use featherfly-conversion version 1.3.4 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.3.4 in Java... and includes  cn.featherfly - featherfly-conversion version 1.3.4 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.4.1 is released. Learn to use featherfly-conversion version 1.4.1 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.4.1 in Java... and includes  cn.featherfly - featherfly-conversion version 1.4.1 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.2.2 is released. Learn to use featherfly-conversion version 1.2.2 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.2.2 in Java... and includes  cn.featherfly - featherfly-conversion version 1.2.2 java...-conversion released The developers of   cn.featherfly - featherfly
Maven dependency for cn.featherfly - featherfly-conversion version 1.3.2 is released. Learn to use featherfly-conversion version 1.3.2 in Maven based Java projects
? Steps to use  cn.featherfly - featherfly-conversion version 1.3.2 in Java... and includes  cn.featherfly - featherfly-conversion version 1.3.2 java...-conversion released The developers of   cn.featherfly - featherfly
currency conversion
currency conversion   hi frds.. I wan jsp code to convert currency in different formats??... if u know plz plz plz post it   Please visit the following link: http://www.roseindia.net/tutorials/I18N/currency
conversion
conversion
ModuleNotFoundError: No module named 'conversion'
ModuleNotFoundError: No module named 'conversion'  Hi, My Python... 'conversion' How to remove the ModuleNotFoundError: No module named 'conversion' error? Thanks   Hi, In your python environment you
html2xml conversion
html2xml conversion  java code to convert html file to xml
Language Conversion
Language Conversion  write a java program to convert "Hello World" in spanish
.wav file conversion
.wav file conversion   how to read .wav file and converd the data into text format
conversion of language in a project
conversion of language in a project  how can we convert the database code in the project dynamically
NSString to float conversion
NSString to float conversion  HI, I my iPhone and iPad application I have to convert NSString to float. Provide me example of NSString to float conversion. Thanks   Hi, Please see NSString to float conversion
NSString to float conversion
NSString to float conversion  HI, I my iPhone and iPad application I have to convert NSString to float. Provide me example of NSString to float conversion. Thanks   HI, Use the following code: NSScanner *strXpos
Version of cn.featherfly>featherfly-conversion dependency
List of Version of cn.featherfly>featherfly-conversion dependency
Version of com.groupdocs>groupdocs-conversion dependency
List of Version of com.groupdocs>groupdocs-conversion dependency
Version of com.ncona>conversion-graph dependency
List of Version of com.ncona>conversion-graph dependency
ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion'
ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' ...: ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' How to remove the ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' error
ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion'
ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' ...: ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' How to remove the ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' error
ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion'
ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' ...: ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' How to remove the ModuleNotFoundError: No module named 'australian_ntv2_grid_conversion' error

Ads