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 666749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:51:10+00:00 2026-05-13T23:51:10+00:00

We can’t use java.text.SimpleDateFormat, so is there any way to create date object from

  • 0

We can’t use java.text.SimpleDateFormat, so is there any way to create date object from year,month,day in Java ME?

  • 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-13T23:51:10+00:00Added an answer on May 13, 2026 at 11:51 pm

    I found solution, Here is the code:

        public static Date parseDate(String dateString) throws IllegalArgumentException {
    Date date = new Date(0);
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    
    System.out.println("Calendar Before "+date);
    
    if (dateString == null || dateString.equals("")) {
    throw new IllegalArgumentException("Invalid String to Parse as Date - dateString was null or empty");
    }
    
    int strSize = dateString.length();
    
    if (strSize < 21) {
    throw new IllegalArgumentException("Invalid String to Parse as Date - dateString invalid string length ("+strSize+")");
    }
    
    String yearStr = dateString.substring(0,4);
    String monthStr = dateString.substring(5,7);
    String dayStr = dateString.substring(8,10);
    String hourStr = dateString.substring(11,13);
    String minuteStr = dateString.substring(14,16);
    String secondsStr = dateString.substring(17,19);
    String millisStr = dateString.substring(20,Math.min(strSize,23));
    
    int year = 0;
    int day = 0;
    int month = 0;
    int hour = 0;
    int minute = 0;
    int seconds = 0;
    int millis = 0;
    
    try {
    year = Integer.parseInt(yearStr);
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+yearStr+"' as a valid year");
    }
    try {
    day = Integer.parseInt(dayStr);
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+dayStr+"' as a valid day");
    }
    try {
    month = Integer.parseInt(monthStr) - 1; //Zero Based Months
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+monthStr+"' as a valid month");
    }
    
    try {
    hour = Integer.parseInt(hourStr);
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+hourStr+"' as a valid hour");
    }
    try {
    minute = Integer.parseInt(minuteStr);
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+minuteStr+"' as a valid minute");
    }
    try {
    seconds = Integer.parseInt(secondsStr);
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+secondsStr+"' as a valid seconds");
    }
    try {
    millis = Integer.parseInt(millisStr);
    } catch (Exception e) {
    throw new DateParseException("Could not parse '"+millisStr+"' as a valid millis");
    }
    
    System.out.println("Y: "+year+" M: "+month+" D: "+day);
    System.out.println("H: "+hour+" m: "+minute+" s: "+seconds+" S: "+millis);
    
    cal.set(Calendar.MONTH,month);
    cal.set(Calendar.DATE,day);
    cal.set(Calendar.YEAR,year);
    cal.set(Calendar.HOUR_OF_DAY,hour);
    cal.set(Calendar.MINUTE,minute);
    cal.set(Calendar.SECOND,seconds);
    
    System.out.println("Date After "+date);
    date = cal.getTime();
    
    return date;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use echo to generate an UTF-8 text file? For example if I
Can any one tell, how to get the result of LINQ query contains group
Can anyone enlighten me to a way I can Highlight the content of an
Can anybody tell what is the best(easy) way to sort the following string 'index'
Can someone guide me on a possible solution? I don't want to use /bin/cp
Can't figure out how to do this in a pretty way : I have
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can someone help me with this scenario? *There is a button, which when tapped,
Can anyone explain me what's going on? I use this method - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
Can any one tell me clearly why ? Reading is simple in ArrayList,( we

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.