ask java

ask java

View Answers

October 10, 2008 at 3:11 PM

Hi friend,


Code to help calculate the month and days :

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class DayDiff {

public static void main(String[] args) {

Date date = new Date();
SimpleDateFormat sdf;

//sdf = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss aa");
sdf = new SimpleDateFormat("yyyy/MM/dd");
System.out.println("date " + sdf.format(date));

//string containing date in one format
String strDate1 = sdf.format(date);
String strDate2 = "2008/09/01";

try
{
//create SimpleDateFormat object with source string date format
SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy/MM/dd");

//parse the string into Date object
Date date1 = sdfSource.parse(strDate1);
Date date2 = sdfSource.parse(strDate2);


long diff = date1.getTime() - date2.getTime();

long diffDays = diff / (24 * 60 * 60 * 1000);
long days =0;
long months=0;
if(diffDays%30!=0)
{
months = Math.round(diffDays/30);
days = diffDays%30;
System.out.println("months : " + months);
System.out.println("days : " + days);
}
if(diffDays%30==0)
{
months = diffDays/30;
System.out.println("months : " + months);

}


}
catch(ParseException pe)
{
System.out.println("Parse Exception : " + pe);
}
}
}

For more information on Java visit to :

http://www.roseindia.net

Thanks



October 10, 2008 at 3:43 PM

Check the Book "Exploring in C"

there this example present









Related Tutorials/Questions & Answers:
Ask about java
Ask about java  Create a java program for add and remove the details of a person, which is not using by database, a simply java program. If possible, please wil it in switch case
ask java - Date Calendar
but in java i found too but i can't to join in another frame. And i want to ask how...ask java  sory i'am wrong language. i want to ask to this forum how... information on Java visit to : http://www.roseindia.net Thanks  
Advertisements
Ask java count
Ask java count  Good morning, I have a case where there are tables... | Java 1 | 10 | | b002 | beginner java | 5 | | b003 | advanced java book | 26 | | b004 | MySQL 1
ask - Java Beginners
ask   dear how to "print out" into a file ? regard suhadi  Hi friend, Please explain properly requirement. I am sending simple...://www.roseindia.net/java/ Thanks. Amardeep
Ask Java Questions Online
Ask Java Questions Online       Now, it’s time to rejoice for the Java... Developer Company has just begun a new service ‘ask question online&rsquo
Ask make graph from i report and view to java Language Programming
Ask make graph from i report and view to java Language Programming  Dear sir, Please help me, i want to make a graph from mysql to i report and view to java. Please help me, give me example source code please. thank you
Maven dependency for com.rationaleemotions - just-ask version 1.0.2 is released. Learn to use just-ask version 1.0.2 in Maven based Java projects
; com.rationaleemotions - just-ask version 1.0.2 in Java projects. Follow the step by step...; com.rationaleemotions - just-ask version 1.0.2 java library in your project...-ask released The developers of   com.rationaleemotions - just-ask
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ModuleNotFoundError: No module named 'ask'
ModuleNotFoundError: No module named 'ask'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ask' How to remove the ModuleNotFoundError: No module named 'ask' error
Ask about looping in database
Ask about looping in database  Good afternoon, I want to ask...=True,A2=True : code is the same data Rule and Heritage. I want to ask that how to read looping in field rights(if A1=false and A2 = True), use from java. i
Ask for latest version for hibernate
Ask for latest version for hibernate  any new version for hibernate after 3.0, if yes can u give some exmp for latest version of hibernate
Ask Questions with Options
Ask Questions with Options using Java In this section, we are going to ask five questions one after the other with four options to test the user. For this, we have stored 5 questions, answers with four options into a list. The list
ModuleNotFoundError: No module named 'ask-sdk'
ModuleNotFoundError: No module named 'ask-sdk'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ask-sdk' How to remove the ModuleNotFoundError: No module named 'ask-sdk
ModuleNotFoundError: No module named 'ask-for-color'
ModuleNotFoundError: No module named 'ask-for-color'  Hi, My... 'ask-for-color' How to remove the ModuleNotFoundError: No module named 'ask-for-color' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-sdk'
ModuleNotFoundError: No module named 'ask-sdk'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ask-sdk' How to remove the ModuleNotFoundError: No module named 'ask-sdk
ModuleNotFoundError: No module named 'falcon-ask'
ModuleNotFoundError: No module named 'falcon-ask'  Hi, My Python... 'falcon-ask' How to remove the ModuleNotFoundError: No module named 'falcon-ask' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'ask-schools'
ModuleNotFoundError: No module named 'ask-schools'  Hi, My Python... 'ask-schools' How to remove the ModuleNotFoundError: No module named 'ask-schools' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ask-schools'
ModuleNotFoundError: No module named 'ask-schools'  Hi, My Python... 'ask-schools' How to remove the ModuleNotFoundError: No module named 'ask-schools' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ask-sdk'
ModuleNotFoundError: No module named 'ask-sdk'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ask-sdk' How to remove the ModuleNotFoundError: No module named 'ask-sdk
ModuleNotFoundError: No module named 'falcon-ask'
ModuleNotFoundError: No module named 'falcon-ask'  Hi, My Python... 'falcon-ask' How to remove the ModuleNotFoundError: No module named 'falcon-ask' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'ask_amy'
ModuleNotFoundError: No module named 'ask_amy'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ask_amy' How to remove the ModuleNotFoundError: No module named 'ask_amy
ModuleNotFoundError: No module named 'ask-for-password'
ModuleNotFoundError: No module named 'ask-for-password'  Hi, My... named 'ask-for-password' How to remove the ModuleNotFoundError: No module named 'ask-for-password' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ask-schools'
ModuleNotFoundError: No module named 'ask-schools'  Hi, My Python... 'ask-schools' How to remove the ModuleNotFoundError: No module named 'ask-schools' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ask-so'
ModuleNotFoundError: No module named 'ask-so'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ask-so' How to remove the ModuleNotFoundError: No module named 'ask-so'
ModuleNotFoundError: No module named 'f-ask'
ModuleNotFoundError: No module named 'f-ask'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'f-ask' How to remove the ModuleNotFoundError: No module named 'f-ask'
ModuleNotFoundError: No module named 'Flask-Ask'
ModuleNotFoundError: No module named 'Flask-Ask'  Hi, My Python... 'Flask-Ask' How to remove the ModuleNotFoundError: No module named 'Flask-Ask' error? Thanks   Hi, In your python environment you
Ask Questions
Ask Questions      ..., professions, students and learners, we have initiated a new service ‘Ask Question’. Using this new service, our visitors can ask any sort of question
Version of com.rationaleemotions>just-ask dependency
List of Version of com.rationaleemotions>just-ask dependency
Ask date difference
Ask date difference  Hello, I have a problem about how to calculate date, the result from this code is not complete , this is my code . please help me. thank you public void a(){ String date1 = jTextField33.getText(); String
ask a user to enter 5 integer
ask a user to enter 5 integer  make a program that enter 5 numbers then identify the largest and the smallest number sample program 2 4 3 5 6 the smallest number: 2 the largest number: is 6 66
Ask JSP questions online
Ask JSP questions online       Facing problem in JSP? Ask to us, we... has just started a new problem solving service ‘ask question’. In our
ModuleNotFoundError: No module named 'ask-academic-dates'
ModuleNotFoundError: No module named 'ask-academic-dates'  Hi, My... named 'ask-academic-dates' How to remove the ModuleNotFoundError: No module named 'ask-academic-dates' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ask-sdk-core'
ModuleNotFoundError: No module named 'ask-sdk-core'  Hi, My Python... 'ask-sdk-core' How to remove the ModuleNotFoundError: No module named 'ask-sdk-core' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-sdk-jinja-renderer'
ModuleNotFoundError: No module named 'ask-sdk-jinja-renderer'  Hi...: No module named 'ask-sdk-jinja-renderer' How to remove the ModuleNotFoundError: No module named 'ask-sdk-jinja-renderer' error? Thanks   Hi
ModuleNotFoundError: No module named 'ask-sdk-model'
ModuleNotFoundError: No module named 'ask-sdk-model'  Hi, My... 'ask-sdk-model' How to remove the ModuleNotFoundError: No module named 'ask-sdk-model' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-sdk-s3-persistence-adapter'
ModuleNotFoundError: No module named 'ask-sdk-s3-persistence-adapter' ...: No module named 'ask-sdk-s3-persistence-adapter' How to remove the ModuleNotFoundError: No module named 'ask-sdk-s3-persistence-adapter' error
ModuleNotFoundError: No module named 'ask-sdk-webservice-support'
ModuleNotFoundError: No module named 'ask-sdk-webservice-support'  Hi...: No module named 'ask-sdk-webservice-support' How to remove the ModuleNotFoundError: No module named 'ask-sdk-webservice-support' error? Thanks
ModuleNotFoundError: No module named 'django-ask-sdk'
ModuleNotFoundError: No module named 'django-ask-sdk'  Hi, My... named 'django-ask-sdk' How to remove the ModuleNotFoundError: No module named 'django-ask-sdk' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'py-ask-sdk-test'
ModuleNotFoundError: No module named 'py-ask-sdk-test'  Hi, My... named 'py-ask-sdk-test' How to remove the ModuleNotFoundError: No module named 'py-ask-sdk-test' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sp-ask-chats-utils'
ModuleNotFoundError: No module named 'sp-ask-chats-utils'  Hi, My... named 'sp-ask-chats-utils' How to remove the ModuleNotFoundError: No module named 'sp-ask-chats-utils' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'ask-alexa-pykit'
ModuleNotFoundError: No module named 'ask-alexa-pykit'  Hi, My... named 'ask-alexa-pykit' How to remove the ModuleNotFoundError: No module named 'ask-alexa-pykit' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-sdk-core'
ModuleNotFoundError: No module named 'ask-sdk-core'  Hi, My Python... 'ask-sdk-core' How to remove the ModuleNotFoundError: No module named 'ask-sdk-core' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-sdk-model'
ModuleNotFoundError: No module named 'ask-sdk-model'  Hi, My... 'ask-sdk-model' How to remove the ModuleNotFoundError: No module named 'ask-sdk-model' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-sdk-model-runtime'
ModuleNotFoundError: No module named 'ask-sdk-model-runtime'  Hi...: No module named 'ask-sdk-model-runtime' How to remove the ModuleNotFoundError: No module named 'ask-sdk-model-runtime' error? Thanks   Hi
ModuleNotFoundError: No module named 'ask-sdk-s3-persistence-adapter'
ModuleNotFoundError: No module named 'ask-sdk-s3-persistence-adapter' ...: No module named 'ask-sdk-s3-persistence-adapter' How to remove the ModuleNotFoundError: No module named 'ask-sdk-s3-persistence-adapter' error
ModuleNotFoundError: No module named 'ask-sdk-webservice-support'
ModuleNotFoundError: No module named 'ask-sdk-webservice-support'  Hi...: No module named 'ask-sdk-webservice-support' How to remove the ModuleNotFoundError: No module named 'ask-sdk-webservice-support' error? Thanks
ModuleNotFoundError: No module named 'ask-smapi-sdk'
ModuleNotFoundError: No module named 'ask-smapi-sdk'  Hi, My... 'ask-smapi-sdk' How to remove the ModuleNotFoundError: No module named 'ask-smapi-sdk' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cherrypy-ask-sdk'
ModuleNotFoundError: No module named 'cherrypy-ask-sdk'  Hi, My... named 'cherrypy-ask-sdk' How to remove the ModuleNotFoundError: No module named 'cherrypy-ask-sdk' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-ask-sdk'
ModuleNotFoundError: No module named 'django-ask-sdk'  Hi, My... named 'django-ask-sdk' How to remove the ModuleNotFoundError: No module named 'django-ask-sdk' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ask-alexa-pykit'
ModuleNotFoundError: No module named 'ask-alexa-pykit'  Hi, My... named 'ask-alexa-pykit' How to remove the ModuleNotFoundError: No module named 'ask-alexa-pykit' error? Thanks   Hi, In your python

Ads