Android Open Source - qrcode-android Date Util






From Project

Back to project page qrcode-android.

License

The source code is released under:

MIT License

If you think the Android project qrcode-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package tw.soleil.util;
/*from  w ww.j  a v  a2  s .c  o  m*/
public class DateUtil {
  public static String getEDateWithSep(String strCDate, String strSep) {
    return getDateWithSep(getEDate(strCDate), strSep);
  }

  public static String getDateWithSep(String strInit, String strSep) {
    StringBuffer sb = null;

    if(strInit == null || strInit.trim().equals("")){
      return "";
    }

    try {

      int dateLen = strInit.length();

      if(dateLen > 5){ 

        String strFirst = strInit.substring(0, dateLen - 4);
        String strSecond = strInit.substring(dateLen - 4, dateLen - 2);
        String strThird = strInit.substring(dateLen - 2);

        sb = new StringBuffer(strFirst);

        sb.append(strSep).append(strSecond).append(strSep).append(strThird);

      } else if (dateLen == 5 || dateLen == 4){
        sb = new StringBuffer(strInit.substring(0, dateLen - 2)).append(strSep)
        .append(strInit.substring(dateLen - 2));

      } else {
        return strInit;
      }

    }
    catch (Exception e) {
      return strInit;
    }

    return sb.toString();
  }
  
  /** REFINE
   * ?????????????????
   * @param strCDate: yyyMMdd
   * @return yyyyMMdd
   */
  public static String getEDate(String strCDate) {
    StringBuffer sbEDate = new StringBuffer();

    if (strCDate != null) {
      int len = strCDate.length();
      String year = strCDate.substring(0, len - 4);
      String month = strCDate.substring(len - 4, len - 2);
      String day = strCDate.substring(len - 2);

      if (year.length() < 4) {
        year = String.valueOf(Integer.valueOf(year).intValue() + 1911);
      } else {
        year = String.valueOf(Integer.valueOf(year).intValue());
      }

      sbEDate.append(year);
      sbEDate.append(month);
      sbEDate.append(day);

    }

    return sbEDate.toString();
  }
}




Java Source Code List

com.google.zxing.client.android.BeepManager.java
com.google.zxing.client.android.CaptureActivityHandler.java
com.google.zxing.client.android.CaptureActivity.java
com.google.zxing.client.android.Contents.java
com.google.zxing.client.android.DecodeFormatManager.java
com.google.zxing.client.android.DecodeHandler.java
com.google.zxing.client.android.DecodeHintManager.java
com.google.zxing.client.android.DecodeThread.java
com.google.zxing.client.android.FinishListener.java
com.google.zxing.client.android.InactivityTimer.java
com.google.zxing.client.android.IntentSource.java
com.google.zxing.client.android.Intents.java
com.google.zxing.client.android.LocaleManager.java
com.google.zxing.client.android.ViewfinderResultPointCallback.java
com.google.zxing.client.android.ViewfinderView.java
com.google.zxing.client.android.camera.AutoFocusManager.java
com.google.zxing.client.android.camera.CameraConfigurationManager.java
com.google.zxing.client.android.camera.CameraManager.java
com.google.zxing.client.android.camera.FrontLightMode.java
com.google.zxing.client.android.camera.PreviewCallback.java
com.google.zxing.client.android.camera.exposure.DefaultExposureInterface.java
com.google.zxing.client.android.camera.exposure.ExposureInterface.java
com.google.zxing.client.android.camera.exposure.ExposureManager.java
com.google.zxing.client.android.camera.exposure.FroyoExposureInterface.java
com.google.zxing.client.android.camera.open.DefaultOpenCameraInterface.java
com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface.java
com.google.zxing.client.android.camera.open.OpenCameraInterface.java
com.google.zxing.client.android.camera.open.OpenCameraManager.java
com.google.zxing.client.android.common.PlatformSupportManager.java
com.google.zxing.client.android.common.executor.AsyncTaskExecInterface.java
com.google.zxing.client.android.common.executor.AsyncTaskExecManager.java
com.google.zxing.client.android.common.executor.DefaultAsyncTaskExecInterface.java
com.google.zxing.client.android.common.executor.HoneycombAsyncTaskExecInterface.java
com.google.zxing.extra.RGBLuminanceSource.java
eu.livotov.zxscan.AutofocusMode.java
eu.livotov.zxscan.ZXScanHelper.java
eu.livotov.zxscan.ZXUserCallback.java
tw.soleil.constant.Constants.java
tw.soleil.qrcodereadertest.QRCodeReaderTestActivity.java
tw.soleil.service.InvoiceService.java
tw.soleil.to.InvoiceDtl.java
tw.soleil.to.Invoice.java
tw.soleil.util.DateUtil.java
tw.soleil.util.Utils.java