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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:10:15+00:00 2026-05-27T13:10:15+00:00

I have a XLSX file which contain 2 columns 1 being a formatted date,

  • 0

I have a XLSX file which contain 2 columns 1 being a formatted date, time or datetime field and other being the relavant format string of type FLEX. So this file contains Flex date format string with formatted value. This files can be contain more than one thousand such combination records.
Eg:

M/D/YYYY L:NN:SS A ——— 7/4/1958 11:34:30 AM

MM/DD/YYYY ——————- 07/13/2009

L:NN:SS A ———————– 1:24:20 PM

What i need to know is, is there anyway that i can validate this given date , time or date time values at right side are formmated according to given FLEX format in the left side.
Important thing is , this need to be happened in java side.

  • 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-27T13:10:16+00:00Added an answer on May 27, 2026 at 1:10 pm
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    Boolean function checkValidity(String date, String flexFormat)
        String s = date;
        String str = flexFormat;
        SimpleDateFormat formatter=new SimpleDateFormat();
        try {
    
            String f = buildFormatString(str);
            formatter.applyPattern(f);
    
            Date d = formatter.parse(s);
            System.out.println(d);
            String nd = formatter.format(d);
            if(nd.compareTo(s) == 0) {
                return true;
            } else {
                return false;
            }
        } catch (ParseException e) {
            e.printStackTrace();
            //This means the format was wrong 
        }
        return false;
    }
    
    //This function changes the Flex date format to the java date format
    //It will not work if the Flex format has text other than the recognised formatting characters.
    private static String buildFormatString(String str) {
    //      The mask pattern. 
    //      You compose a pattern String using specific uppercase letters, for example: YYYY/MM.
    //
    //      The DateFormatter pattern String can contain other text in addition to pattern letters. To form a valid pattern String, you only need one pattern letter.
    //
    //      The following table describes the valid pattern letters:
    //
    //      Pattern letter Description 
    //      Y Year. If the number of pattern letters is two, the year is truncated to two digits; otherwise, it appears as four digits. The year can be zero-padded, as the third example shows in the following set of examples: 
    //      YY = 05 
    //      YYYY = 2005 
    //      YYYYY = 02005 
    
            String jFormat = str;
            jFormat = jFormat.replaceAll("Y", "y");
    
    //       
    //      M Month in year. The format depends on the following criteria: 
    //      If the number of pattern letters is one, the format is interpreted as numeric in one or two digits. 
    //      If the number of pattern letters is two, the format is interpreted as numeric in two digits. 
    //      If the number of pattern letters is three, the format is interpreted as short text. 
    //      If the number of pattern letters is four, the format is interpreted as full text. 
    //      Examples: 
    //      M = 7 
    //      MM= 07 
    //      MMM=Jul 
    //      MMMM= July 
    
    
    //       
    //      D Day in month. While a single-letter pattern string for day is valid, you typically use a two-letter pattern string. 
    //      Examples:
    //
    //      D=4 
    //      DD=04 
    //      DD=10 
    
            jFormat = jFormat.replaceAll("D", "d");
    
    //       
    //      E Day in week. The format depends on the following criteria: 
    //      If the number of pattern letters is one, the format is interpreted as numeric in one or two digits. 
    //      If the number of pattern letters is two, the format is interpreted as numeric in two digits. 
    //      If the number of pattern letters is three, the format is interpreted as short text. 
    //      If the number of pattern letters is four, the format is interpreted as full text. 
    //      Examples: 
    //      E = 1 
    //      EE = 01 
    //      EEE = Mon 
    //      EEEE = Monday 
    
    
    
    //       
    //      A am/pm indicator. 
    
            jFormat = jFormat.replaceAll("A", "a");
    
    //      H Hour in day (1-24). 
            jFormat = jFormat.replaceAll("H", "k");
    
    
    //      J Hour in day (0-23). 
            jFormat = jFormat.replaceAll("J", "H");
    
    
    //      K Hour in am/pm (0-11). 
            //jFormat = jFormat.replaceAll("K", "K");
    
    //      L Hour in am/pm (1-12).
            jFormat = jFormat.replaceAll("L", "h");
    
    //      N Minute in hour.
            jFormat = jFormat.replaceAll("N", "m");
    
    //      Examples:
    //
    //      N = 3 
    //      NN = 03 
    //       
    //      S Second in minute. 
            jFormat = jFormat.replaceAll("S", "s");
    
    //      Example:
    //
    //      SS = 30 
    //       
    //      Q Millisecond in second
            jFormat = jFormat.replaceAll("Q", "S");
    
    //      Example:
    //
    //      QQ = 78 
    //      QQQ = 078 
    //       
    //      Other text You can add other text into the pattern string to further format the string. You can use punctuation, numbers, and all lowercase letters. You should avoid uppercase letters because they may be interpreted as pattern letters. 
    //      Example:
    //
    //      EEEE, MMM. D, YYYY at L:NN:QQQ A = Tuesday, Sept. 8, 2005 at 1:26:012 PM 
    //       
    //
    //      Language Version:
    //      3.0
    //      Player Version:
    //      Flash 9, AIR 1.1
    //      Product Version:
    //      Flex 3
            return jFormat;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to open an xlsx file, I have tried the below code,but neither
I have a GridView which is like: File Name DateTimeUploaded Type Resume 1/13/2012 7:52:59
I have this C# code which converts a dataset to xlsx. Is there a
I have a huge xlsx file (aboutn 127 MB) and want to read using
I am using Apache POI to read xlsx file, it works well. I have
i have data stored in xlsx file with one column of image. how can
I have added a .xlsx file to a shared documents folder in sharepoint 2010.
I have a gridview with coloumns ID, filename, type, date & time and view.
I have a .xlsx file that I wish to launch in Excel from C#.
Hello I have this code where i create an xlsx file and i need

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.