Java Date Convert convertDateTimeToSysTime(String sDateTime)

Here you can find the source of convertDateTimeToSysTime(String sDateTime)

Description

convert Date Time To Sys Time

License

Apache License

Declaration

public static long convertDateTimeToSysTime(String sDateTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

public class Main {

    public static long convertDateTimeToSysTime(String sDateTime) {
        int nYear = Integer.parseInt(sDateTime.substring(0, 4));
        int nMonth = Integer.parseInt(sDateTime.substring(4, 6));
        int nDay = Integer.parseInt(sDateTime.substring(6, 8));
        int nHour = 0, nMinute = 0, nSecond = 0;
        if (sDateTime.length() == 14) {
            nHour = Integer.parseInt(sDateTime.substring(8, 10));
            nMinute = Integer.parseInt(sDateTime.substring(10, 12));
            nSecond = Integer.parseInt(sDateTime.substring(12, 14));
        }/*  w  ww .j a va  2 s . c  o m*/
        Calendar calendar = Calendar.getInstance();
        calendar.set(nYear, nMonth - 1, nDay, nHour, nMinute, nSecond);
        return calendar.getTime().getTime();
    }
}

Related

  1. convert(Date d)
  2. convertDate(Object obj)
  3. convertDateTime(String date, String time)
  4. ConvertDateToAge(String date)
  5. convertDateToDoubleTime(Date time)
  6. convertDateToInt(final Date date)
  7. convertDateToLong(int year, int month, int day, int hour, int minute, int second)