Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:35:53+00:00 2026-05-24T09:35:53+00:00

I have 50000 XML records like this in the database: <?xml version=1.0 encoding=UTF-8?> <root>

  • 0

I have 50000 XML records like this in the database:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<urlMD5>11ca7070ad6eb3180c53281e7b597976</urlMD5>
<date>
<year>2011</year>
<month>8</month>
<day>6</day>
<h>19</h>
<m>26</m>
<s>40</s>
</date>
<enc>utf-8</enc>
</root>

as you see, I saved the date in separated format.
Now I need to extract the currentTimeMillis() of these days and save to database in new field.
So I can easily compare them with current currentTimeMillis() and find out which document have been stored in last two days.
for example:

int ct = currentTimeMillis();

Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/crawler?" + "user=root&password=&useUnicode=true&characterEncoding=UTF-8");
Statement stat = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM DBName WHERE ct - 60 * 60 * 24 * 2 > timeField");

And because I want to use this field for so many times, I want to use a simple query and I don’t want to extract the XML format each time.

The problem is currentTimeMillis() function calculate currentTimeMillis that passed from January 1, 1970 and I need to calculate the same thing with my data.
I have written following code with the same code that I used before to store XML data to make sure if I can do it or not:

int s = 0;
s += (Calendar.getInstance().get(Calendar.YEAR) - 1970) * 60 * 60 * 24 * 365;
s += (Calendar.getInstance().get(Calendar.MONTH)) * 60 * 60 * 24 * 31;
s += (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) * 60 * 60 * 24);
s += (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) * 60 * 60);
s += (Calendar.getInstance().get(Calendar.MINUTE) * 60);
s += (Calendar.getInstance().get(Calendar.SECOND));
System.out.println(s);
System.out.println(System.currentTimeMillis() / 1000);

but the results are not the same:

1312313680
1312643080

One of the reasons is because not every month have 31 days.

Any way, I need help to find out how can I calculate the currentTimeMillis with special date, not the current date?

I should mention that I am using mysql, so maybe I can save the dates in special format that I can compare the with SQL query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:35:53+00:00Added an answer on May 24, 2026 at 9:35 am

    Use the set method of Calendar:

    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, month);
    

    etc.

    And then extract the number of milliseconds with c.getTime().getTime().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML File <?xml version=1.0 encoding=UTF-8?> <data> <contact-information> <full-name>Peter John</full-name> <address_line_1>some place</address_line_1>
I have an xml like this: <todo> <doLaundry cost=1/> <washCar cost=10/> <tidyBedroom cost=0 experiencePoints=5000/>
I have an xml file like this : <products> <cars> <car> <brand>Audi</brand> <type>S3</type> <attribs>
I have a datasource set in my Jetty.xml file that looks like this: <New
I have a double thats got a value of something like 0.50000 but I
I am using ASPNET membership with 50000 records, and we have another table called
I have my web config as follows <?xml version=1.0?> <configuration> <appSettings/> <connectionStrings> <add name=MySqlConnection
There's an XML scheme which says something like this: <ExtraFields> <ExtraField Type=Int> <Key>Mileage</Key> <Value>500000
I have this XML <data> <peptides> <peptide> <accession>111</accession> <sequence>AAA</sequence> <score>4000</score> </peptide> <peptide> <accession>111</accession> <sequence>AAA</sequence>
I have this code in PHP: <?php $data = file_get_contents('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml'); $xml = simplexml_load_string($data); echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.