Hello!
I can convert from the given date,month and year to a day of year with the following code.
GregorianCalendar cal = (GregorianCalendar)Calendar.getInstance();
cal.set(1996,0,1);
System.out.println(cal.get(cal.DAY_OF_YEAR));
Answer : 1
My question is now i want to do opposite for eksempel i want to convert from the given year(1996) and a day of year(256) to date. How i can do that?
I need help .
Malik
8 1568
Hello!
I can convert from the given date,month and year to a day of year with the following code.
GregorianCalendar cal = (GregorianCalendar)Calendar.getInstance();
cal.set(1996,0,1);
System.out.println(cal.get(cal.DAY_OF_YEAR));
Answer : 1
My question is now i want to do opposite for eksempel i want to convert from the given year(1996) and a day of year(256) to date. How i can do that?
I need help .
Malik
Create a new Calendar. Set it's Date to 1 January 1996. Add 256 to it's date field and you have the date.
Create a new Calendar. Set it's Date to 1 January 1996. Add 256 to it's date field and you have the date.
Problem:
I have just year(1996) and a day of year(256).I want to convert this into a date.I donot have month and date,that i am trying now. How i can do that?
I am very thankful to you.
malik123
Problem:
I have just year(1996) and a day of year(256).I want to convert this into a date.I donot have month and date,that i am trying now. How i can do that?
I am very thankful to you.
malik123
Do you know how to set the Date field of a gc to 1 January 1996?
Do you know how to set the Date field of a gc to 1 January 1996?
I didnot understand but you mean
GregorianCalendar cal = (GregorianCalendar)Calendar.getInstance();
cal.set(1996,0,1);
I didnot understand but you mean
GregorianCalendar cal = (GregorianCalendar)Calendar.getInstance();
cal.set(1996,0,1);
Isn't it supposed to be - GregorianCalendar gc = new GregorianCalendar();
-
gc.setTime(Date.valueOf("1996-01-01"));
-
Check the docs for java.sql.Date and for GregorianCalendar.
then you can do gc.add(GregorianCalendar.DAY, 256);
I have tried but not found the correct result.
I tried to explain my problem once again. I have just two inputs Year and Day of year for example we have year "2007" and day of year "39".
From these two inputs i need following output.
I want to get the output in date,month and year which is "8 Februar 2007".How i can do that.
I am very thankful to you.
malik123
I have tried but not found the correct result.
I tried to explain my problem once again. I have just two inputs Year and Day of year for example we have year "2007" and day of year "39".
From these two inputs i need following output.
I want to get the output in date,month and year which is "8 Februar 2007".How i can do that.
I am very thankful to you.
malik123
Have you been reading what I've been posting? What happened when you tried it?
I have found it.
The exact code is
int å=2007;
int d=39;
GregorianCalendar cal = (GregorianCalendar)Calendar.getInstance();
cal.set(å,0,1);
cal.set(Calendar.DAY_OF_YEAR,d);
System.Out.println( (cal.get(cal.DATE))+"-"+(cal.get(cal.MONTH)+1)+"-"+å);
Result is : 8-02-2007
I have done it.Thanks for helping me.
malik123
Sign in to post your reply or Sign up for a free account.
Similar topics
by: - |
last post by:
Hello to all
I need help on some sql statements and wondering is anyone out there is able
to help.
I've extracted some data from the database into a new table consisting of 4
fields
CustomerID...
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my...
|
by: Lyn |
last post by:
I am trying to get my head around the concept of default, special or empty
values that appear in Access VBA, depending on data type. The Access Help
is not much (help), and the manual that I have...
|
by: James Radke |
last post by:
Hello,
I have a multithreaded windows NT service application (vb.net 2003) that I
am working on (my first one), which reads a message queue and creates
multiple threads to perform the processing...
|
by: Brian Henry |
last post by:
Ok I've never implemented a snap location before so I dont really know what
im doing wrong here... anyways, I am making a custom slider control that
takes dates as its values instead of integers......
|
by: JonathanParker |
last post by:
Looking for some help urgently with some VB SQL Access stuff. You'll have to excuse the messiness of the code, I'm a newbie at all this. I'm running this code with a selection of check boxes to...
|
by: Takeadoe |
last post by:
Dear NG,
Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the...
|
by: Bill |
last post by:
I have a 200 record database that includes a date/time field,
AnnivDate, for a wedding anniversary. AnnivDate has nulls and some
incorrect year data. I have been creating the Access database...
|
by: kr151080 |
last post by:
Ok so I am messing around with a program and have no idea how to go about doing this but here is the code for the class date....
public class Date
{
private int dMonth;
private int dDay;...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |