org.joda.time.DateTime.getMillisOfSecond()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(241)

本文整理了Java中org.joda.time.DateTime.getMillisOfSecond()方法的一些代码示例,展示了DateTime.getMillisOfSecond()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.getMillisOfSecond()方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:getMillisOfSecond

DateTime.getMillisOfSecond介绍

暂无

代码示例

代码示例来源:origin: alibaba/canal

if (val instanceof java.sql.Time) {
  DateTime dateTime = new DateTime(((java.sql.Time) val).getTime());
  if (dateTime.getMillisOfSecond() != 0) {
    res = dateTime.toString("HH:mm:ss.SSS");
  } else {
  if (dateTime.getMillisOfSecond() != 0) {
    res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00");
  } else {
    && dateTime.getMillisOfSecond() == 0) {
    res = dateTime.toString("yyyy-MM-dd");
  } else {
    if (dateTime.getMillisOfSecond() != 0) {
      res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00");
    } else {
  DateTime dateTime = new DateTime(((Long) val).longValue());
  if (dateTime.getHourOfDay() == 0 && dateTime.getMinuteOfHour() == 0 && dateTime.getSecondOfMinute() == 0
    && dateTime.getMillisOfSecond() == 0) {
    res = dateTime.toString("yyyy-MM-dd");
  } else if (dateTime.getMillisOfSecond() != 0) {
    res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00");
  } else {
    String dt = v.substring(0, 10) + "T" + v.substring(11);
    DateTime dateTime = new DateTime(dt);
    if (dateTime.getMillisOfSecond() != 0) {
      res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00");

代码示例来源:origin: apache/incubator-pinot

case MILLISECONDS:
 _dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter
   .print(dateTime.withMillisOfSecond((dateTime.getMillisOfSecond() / sz) * sz));
 break;
case SECONDS:

代码示例来源:origin: org.elasticsearch/elasticsearch

bucket.saveField(DateTimeFieldType.minuteOfHour(), dt.getMinuteOfHour());
  bucket.saveField(DateTimeFieldType.secondOfMinute(), dt.getSecondOfMinute());
  bucket.saveField(DateTimeFieldType.millisOfSecond(), dt.getMillisOfSecond());
  bucket.setZone(DateTimeZone.UTC);
} catch (Exception e) {

代码示例来源:origin: actiontech/dble

/**
 * getMicroSecond
 *
 * @param date
 * @return
 */
public static int getMicroSecond(Date date) {
  DateTime dt = new DateTime(date);
  return dt.getMillisOfSecond();
}

代码示例来源:origin: stackoverflow.com

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class ParseMillis {

 public static void main(String[] args) {
  String s = "00:00:01.2";
  DateTimeFormatter format = DateTimeFormat.forPattern("HH:mm:ss.S");
  DateTime dateTime = format.parseDateTime(s);
  System.out.println(dateTime.getMillisOfSecond());
 }
}

代码示例来源:origin: metatron-app/metatron-discovery

private List<DateTime> getMillisLabels(DateTime min, DateTime max, int unitSize) {
 List<DateTime> labels = new ArrayList<>();
 DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
     min.getHourOfDay(), min.getMinuteOfHour(), min.getSecondOfMinute(), min.getMillisOfSecond() / unitSize * unitSize);
 while (dt.isBefore(max) || dt.isEqual(max)) {
  labels.add(dt);
  dt = dt.plusMillis(unitSize);
 }
 labels.add(dt);
 return labels;
}

代码示例来源:origin: edu.ucar/netcdf

static public String toDateTimeString(CalendarDate cd) {
  if(cd.getDateTime().getMillisOfSecond()==0)	  
    return dtf.print(cd.getDateTime());
  else
    return dtf_with_millis_of_second.print(cd.getDateTime());
}

代码示例来源:origin: edu.ucar/cdm

static public String toDateTimeStringISO(CalendarDate cd) {
 
  if(cd.getDateTime().getMillisOfSecond() == 0)
    return isof.print( cd.getDateTime() );
  else
    return isof_with_millis_of_second.print(cd.getDateTime());
  }

代码示例来源:origin: edu.ucar/cdm

static public String toDateTimeString(CalendarDate cd) {
  if(cd.getDateTime().getMillisOfSecond()==0)	  
    return dtf.print(cd.getDateTime());
  else
    return dtf_with_millis_of_second.print(cd.getDateTime());
}

代码示例来源:origin: edu.ucar/netcdf

static public String toDateTimeStringISO(CalendarDate cd) {
 
  if(cd.getDateTime().getMillisOfSecond() == 0)
    return isof.print( cd.getDateTime() );
  else
    return isof_with_millis_of_second.print(cd.getDateTime());
  }

代码示例来源:origin: Unidata/thredds

static public String toDateTimeStringISO(CalendarDate cd) {
 
  if(cd.getDateTime().getMillisOfSecond() == 0)
    return isof.print( cd.getDateTime() );
  else
    return isof_with_millis_of_second.print(cd.getDateTime());
  }

代码示例来源:origin: Unidata/thredds

static public String toDateTimeString(CalendarDate cd) {
  if(cd.getDateTime().getMillisOfSecond()==0)	  
    return dtf.print(cd.getDateTime());
  else
    return dtf_with_millis_of_second.print(cd.getDateTime());
}

代码示例来源:origin: org.apache.pig/pig

@Override
public Integer exec(Tuple input) throws IOException {
  if (input == null || input.size() < 1 || input.get(0) == null) {
    return null;
  }
  return ((DateTime) input.get(0)).getMillisOfSecond();
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Get the microsecond part of this time value.
 *
 * @return the (whole) microsecond part of time
 */
@JRubyMethod(name = {"usec", "tv_usec"})
public RubyInteger usec() {
  return getRuntime().newFixnum(dt.getMillisOfSecond() * 1000 + getUSec());
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Get the microsecond part of this time value.
 *
 * @return the (whole) microsecond part of time
 */
@JRubyMethod(name = {"usec", "tv_usec"})
public RubyInteger usec() {
  return getRuntime().newFixnum(dt.getMillisOfSecond() * 1000 + getUSec());
}

代码示例来源:origin: org.jruby/jruby-core

private static RubyDateTime calcAjdFromCivil(ThreadContext context, final DateTime dt, final int off,
                       final long subMillisNum, final long subMillisDen) {
  final Ruby runtime = context.runtime;
  long jd = civil_to_jd(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), ITALY);
  RubyNumeric fr = timeToDayFraction(context, dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute());
  final RubyNumeric ajd = jd_to_ajd(context, jd, fr, off);
  RubyDateTime dateTime = new RubyDateTime(context, getDateTime(runtime), ajd, off, ITALY);
  dateTime.dt = dateTime.dt.withMillisOfSecond(dt.getMillisOfSecond());
  dateTime.subMillisNum = subMillisNum; dateTime.subMillisDen = subMillisDen;
  return dateTime;
}

代码示例来源:origin: org.openehr.java-libs/openehr-rm-core

/**
 * Parses a string value and return a DvTime
 */
public DvTime parse(String value) {
  DateTime time = DvDateTimeParser.parseTime(value);
  return new DvTime(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), time.getZone().toTimeZone());
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod(name = "sec_fraction", alias = "second_fraction", visibility = Visibility.PRIVATE)
public RubyNumeric sec_fraction(ThreadContext context) {
  long ms = dt.getMillisOfSecond();
  if (subMillisDen == 1) {
    return (RubyNumeric) RubyRational.newRationalCanonicalize(context, ms + subMillisNum, 1000);
  }
  final Ruby runtime = context.runtime;
  RubyNumeric sum = RubyRational.newRational(runtime, ms, 1).op_plus(context, subMillis(runtime));
  return sum.convertToRational().op_div(context, RubyFixnum.newFixnum(runtime, 1000));
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod(name = "sec_fraction", alias = "second_fraction", visibility = Visibility.PRIVATE)
public RubyNumeric sec_fraction(ThreadContext context) {
  long ms = dt.getMillisOfSecond();
  if (subMillisDen == 1) {
    return (RubyNumeric) RubyRational.newRationalCanonicalize(context, ms + subMillisNum, 1000);
  }
  final Ruby runtime = context.runtime;
  RubyNumeric sum = RubyRational.newRational(runtime, ms, 1).op_plus(context, subMillis(runtime));
  return sum.convertToRational().op_div(context, RubyFixnum.newFixnum(runtime, 1000));
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod(name = "day_fraction")
public RubyNumeric day_fraction(ThreadContext context) { // Rational(millis, 86_400_000)
  long ms = dt.getSecondOfDay() * 1000L + dt.getMillisOfSecond();
  if (subMillisDen == 1) {
    return (RubyNumeric) RubyRational.newRationalCanonicalize(context, ms + subMillisNum, DAY_MS);
  }
  final Ruby runtime = context.runtime;
  RubyNumeric sum = RubyRational.newRational(runtime, ms, 1).op_plus(context, subMillis(runtime));
  return sum.convertToRational().op_div(context, RubyFixnum.newFixnum(runtime, DAY_MS));
}

相关文章

DateTime类方法