当前位置: 首页>>代码示例>>Java>>正文


Java JsDate.create方法代码示例

本文整理汇总了Java中com.google.gwt.core.client.JsDate.create方法的典型用法代码示例。如果您正苦于以下问题:Java JsDate.create方法的具体用法?Java JsDate.create怎么用?Java JsDate.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.core.client.JsDate的用法示例。


在下文中一共展示了JsDate.create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDateInAndOut

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
@Test
public void testDateInAndOut() throws Throwable {
    String json = Resources.INSTANCE.minimalDateMeta().getText();
    JsDate dateIn = JsDate.create();
    dateIn.setUTCFullYear(1914);
    dateIn.setUTCMonth(4);
    dateIn.setUTCDate(15);
    dateIn.setUTCHours(22);
    dateIn.setUTCMinutes(13);
    test(json, "SELECT dob FROM person WHERE dob = ?", args(dateIn), null);

    builder.fireDirty();

    assertEquals(1, getLastArgs(conf).length());
    JsDate dateOut = getLastArgs(conf).getObject(0);
    assertEquals(1914, dateOut.getUTCFullYear());
    assertEquals(4, dateOut.getUTCMonth());
    assertEquals(15, dateOut.getUTCDate());
    assertEquals(22, dateOut.getUTCHours());
    assertEquals(13, dateOut.getUTCMinutes());
}
 
开发者ID:salk31,项目名称:RedQueryBuilder,代码行数:22,代码来源:GwtTestBasics.java

示例2: convert

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
@Override
public JsMessage convert(Message value) {
    JsMessenger messenger = JsMessenger.getInstance();

    String rid = value.getRid() + "";
    String sortKey = value.getSortDate() + "";

    JsPeerInfo sender = messenger.buildPeerInfo(Peer.user(value.getSenderId()));
    boolean isOut = value.getSenderId() == messenger.myUid();
    boolean isOnServer = value.isOnServer();
    String date = messenger.getFormatter().formatTime(value.getDate());
    JsDate fullDate = JsDate.create(value.getDate());

    JsContent content = JsContent.createContent(value.getContent(),
            value.getSenderId());

    JsArray<JsReaction> reactions = JsArray.createArray().cast();

    for (Reaction r : value.getReactions()) {
        JsArrayInteger uids = (JsArrayInteger) JsArrayInteger.createArray();
        boolean isOwnSet = false;
        for (Integer i : r.getUids()) {
            uids.push(i);
            if (i == messenger.myUid()) {
                isOwnSet = true;
            }
        }
        reactions.push(JsReaction.create(r.getCode(), uids, isOwnSet));
    }
    double sortDate = value.getDate() / 1000.0;
    return create(rid, sortKey, sender, isOut, date, fullDate, Enums.convert(value.getMessageState()), isOnServer, content,
            reactions, sortDate);
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:34,代码来源:JsMessage.java

示例3: toModelValue

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
@Override
public Date toModelValue(final String widgetValue) {
  if (widgetValue == null || widgetValue.equals("")) {
    return null;
  }

  final JsDate jsDate = JsDate.create(widgetValue);
  return new Date((long) jsDate.getTime());
}
 
开发者ID:mbarkley,项目名称:errai-crud,代码行数:10,代码来源:DateConverter.java

示例4: toWidgetValue

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
@Override
public String toWidgetValue(final Date modelValue) {
  if (modelValue == null) {
    return "";
  } else {
    final JsDate jsDate = JsDate.create(((Long) modelValue.getTime()).doubleValue());
    return toISODate(jsDate);
  }
}
 
开发者ID:mbarkley,项目名称:errai-crud,代码行数:10,代码来源:DateConverter.java

示例5: toJsDate

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
/**
 * Convert the given java date to a javascript one.
 * 
 * @param date
 *			Date to convert (can be <code>null</code>).
 * @return A corresponding javascript date object.
 */
public static JsDate toJsDate(final Date date) {
	if (date != null) {
		return JsDate.create(date.getTime());
	} else {
		return null;
	}
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:15,代码来源:Values.java

示例6: testJsList

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
public void testJsList() throws Throwable {
    JsDate dateIn = JsDate.create();
    dateIn.setUTCFullYear(1914);
    dateIn.setUTCMonth(4);
    dateIn.setUTCDate(15);
    dateIn.setUTCHours(22);
    dateIn.setUTCMinutes(13);

    JsArrayMixed mixed = (JsArrayMixed) JsArrayMixed.createArray();
    mixed.push(dateIn);
    mixed.push(new Double(123.12d));
    mixed.push("123");
    mixed.push("false");

    List<Object> list = JsList.get().toList(mixed);
    Date dateOut = (Date) list.get(0);
    Date dateOutUtc = new Date(dateOut.getTime() + 60 * 1000 * dateOut.getTimezoneOffset());
    assertEquals(14, dateOutUtc.getYear());
    assertEquals(4, dateOutUtc.getMonth());
    assertEquals(15, dateOutUtc.getDate());
    assertEquals(22, dateOutUtc.getHours());
    assertEquals(13, dateOutUtc.getMinutes());

    assertEquals(new Double(123.12d), list.get(1));
    assertEquals("123", list.get(2));
    assertEquals("false", list.get(3));
}
 
开发者ID:salk31,项目名称:RedQueryBuilder,代码行数:28,代码来源:GwtTestBasics.java

示例7: convert

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
@Override
public JsMessage convert(Message value) {
    JsMessenger messenger = JsMessenger.getInstance();

    String rid = value.getRid() + "";
    String sortKey = value.getSortDate() + "";

    JsPeerInfo sender = messenger.buildPeerInfo(Peer.user(value.getSenderId()));
    boolean isOut = value.getSenderId() == messenger.myUid();
    boolean isOnServer = value.isOnServer();
    String date = messenger.getFormatter().formatTime(value.getDate());
    JsDate fullDate = JsDate.create(value.getDate());

    JsContent content;
    if (value.getContent() instanceof TextContent) {
        TextContent textContent = (TextContent) value.getContent();

        String text = ((TextContent) value.getContent()).getText();

        String markdownText = null;
        if (textContent.getTextMessageEx() instanceof ApiTextExMarkdown) {
            markdownText = ((ApiTextExMarkdown) textContent.getTextMessageEx()).getMarkdown();
        }

        content = JsContentText.create(text, markdownText);
    } else if (value.getContent() instanceof ServiceContent) {
        content = JsContentService.create(messenger.getFormatter().formatFullServiceMessage(value.getSenderId(), (ServiceContent) value.getContent()));
    } else if (value.getContent() instanceof DocumentContent) {
        DocumentContent doc = (DocumentContent) value.getContent();

        String fileName = doc.getName();
        String fileExtension = doc.getExt();
        String fileSize = messenger.getFormatter().formatFileSize(doc.getSource().getSize());
        String fileUrl = null;

        if (doc.getSource() instanceof FileRemoteSource) {
            fileUrl = messenger.getFileUrl(((FileRemoteSource) doc.getSource()).getFileReference());
        }

        boolean isUploading = doc.getSource() instanceof FileLocalSource;

        String thumb = null;
        if (doc.getFastThumb() != null) {
            String thumbBase64 = Base64Utils.toBase64(doc.getFastThumb().getImage());
            thumb = "data:image/jpg;base64," + thumbBase64;
        }

        if (value.getContent() instanceof PhotoContent && thumb != null) {
            PhotoContent photoContent = (PhotoContent) value.getContent();
            content = JsContentPhoto.create(
                    fileName, fileExtension, fileSize,
                    photoContent.getW(), photoContent.getH(), thumb,
                    fileUrl, isUploading);
        } else {
            content = JsContentDocument.create(fileName, fileExtension, fileSize,
                    thumb, fileUrl, isUploading);
        }

    } else {
        content = JsContentUnsupported.create();
    }

    return create(rid, sortKey, sender, isOut, date, fullDate, Enums.convert(value.getMessageState()), isOnServer, content);
}
 
开发者ID:dsaved,项目名称:africhat-platform-0.1,代码行数:65,代码来源:JsMessage.java

示例8: testLocalTime

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
private void testLocalTime(Interval interval, String givenDateStr,
			String expectedFloorDateStr, String expectedCeilDateStr,
			String expectedRoundDateStr, String expectedOffset3DateStr) {
		double givenDoubleDate = parseDate(givenDateStr);
		JsDate givenJsDate = JsDate.create(givenDoubleDate);
		Date givenDate = new Date((long) givenDoubleDate);
		
		double expectedFloorDate = parseDate(expectedFloorDateStr);
		assertDateEquals("apply on double", expectedFloorDate, interval.apply(givenDoubleDate));
		assertDateEquals("apply on JsDate", expectedFloorDate, interval.apply(givenJsDate).getTime());
		assertDateEquals("apply on Date", expectedFloorDate, interval.apply(givenDate).getTime());
		
		assertDateEquals("floor on double", expectedFloorDate, interval.floor(givenDoubleDate));
		assertDateEquals("floor on JsDate", expectedFloorDate, interval.floor(givenJsDate).getTime());
		assertDateEquals("floor on Date", expectedFloorDate, interval.floor(givenDate).getTime());
		
		double expectedCeilDate = parseDate(expectedCeilDateStr);
		assertDateEquals("ceil on double", expectedCeilDate, interval.ceil(givenDoubleDate));
		assertDateEquals("ceil on JsDate", expectedCeilDate, interval.ceil(givenJsDate).getTime());
		assertDateEquals("ceil on Date", expectedCeilDate, interval.ceil(givenDate).getTime());
		
		double expectedRoundDate = parseDate(expectedRoundDateStr);
		assertDateEquals("round on double", expectedRoundDate, interval.round(givenDoubleDate));
		assertDateEquals("round on JsDate", expectedRoundDate, interval.round(givenJsDate).getTime());
		assertDateEquals("round on Date", expectedRoundDate, interval.round(givenDate).getTime());
		
		double expectedOffset3Date = parseDate(expectedOffset3DateStr);
		assertDateEquals("offset 3 on double", expectedOffset3Date, interval.offset(givenDoubleDate, 3));
		assertDateEquals("offset 3 on JsDate", expectedOffset3Date, interval.offset(givenJsDate, 3).getTime());
		assertDateEquals("offset 3 on Date", expectedOffset3Date, interval.offset(givenDate, 3).getTime());
		
		JsDate givenJsStart = givenJsDate;
		JsDate givenJsEnd = JsDate.create(expectedOffset3Date);
		assertEquals("range 3 on double", 3, interval.range(givenJsStart.getTime(), givenJsEnd.getTime()).length());
		assertEquals("range 3 on JsDate", 3, interval.range(givenJsStart, givenJsEnd).length());
		Date givenStart = givenDate;
		Date givenEnd = new Date((long) expectedOffset3Date);
		assertEquals("range 3 on Date", 3, interval.range(givenStart, givenEnd).length());
		
		// FIXME : very strange behaviour on this one
//		assertEquals("range 3 with step on double", 2, interval.range(givenJsStart.getTime(), givenJsEnd.getTime(), 2).length());
//		assertEquals("range 3 with step on JsDate", 2, interval.range(givenJsStart, givenJsEnd, 2).length());
//		assertEquals("range 3 with step on Date", 2, interval.range(givenStart, givenEnd, 2).length());
	}
 
开发者ID:gwtd3,项目名称:gwt-d3,代码行数:45,代码来源:TestTimeIntervals.java

示例9: testUTC

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
private void testUTC(Interval interval, String givenDateStr,
			String expectedFloorDateStr, String expectedCeilDateStr,
			String expectedRoundDateStr, String expectedOffset3DateStr) {
		double givenDoubleDate = parseDate(givenDateStr + " GMT+0000");
		JsDate givenJsDate = JsDate.create(givenDoubleDate);
		Date givenDate = new Date((long) givenDoubleDate);
		
		double expectedFloorDate = parseDate(expectedFloorDateStr + " GMT+0000");
		assertDateEquals("apply on double", expectedFloorDate, interval.utc().apply(givenDoubleDate));
		assertDateEquals("apply on JsDate", expectedFloorDate, interval.utc().apply(givenJsDate).getTime());
		assertDateEquals("apply on Date", expectedFloorDate, interval.utc().apply(givenDate).getTime());
		
		assertDateEquals("floor on double", expectedFloorDate, interval.utc().floor(givenDoubleDate));
		assertDateEquals("floor on JsDate", expectedFloorDate, interval.utc().floor(givenJsDate).getTime());
		assertDateEquals("floor on Date", expectedFloorDate, interval.utc().floor(givenDate).getTime());
		
		double expectedCeilDate = parseDate(expectedCeilDateStr + " GMT+0000");
		assertDateEquals("ceil on double", expectedCeilDate, interval.utc().ceil(givenDoubleDate));
		assertDateEquals("ceil on JsDate", expectedCeilDate, interval.utc().ceil(givenJsDate).getTime());
		assertDateEquals("ceil on Date", expectedCeilDate, interval.utc().ceil(givenDate).getTime());
		
		double expectedRoundDate = parseDate(expectedRoundDateStr + " GMT+0000");
		assertDateEquals("round on double", expectedRoundDate, interval.utc().round(givenDoubleDate));
		assertDateEquals("round on JsDate", expectedRoundDate, interval.utc().round(givenJsDate).getTime());
		assertDateEquals("round on Date", expectedRoundDate, interval.utc().round(givenDate).getTime());
		
		double expectedOffset3Date = parseDate(expectedOffset3DateStr + " GMT+0000");
		assertDateEquals("offset 3 on double", expectedOffset3Date, interval.utc().offset(givenDoubleDate, 3));
		assertDateEquals("offset 3 on JsDate", expectedOffset3Date, interval.utc().offset(givenJsDate, 3).getTime());
		assertDateEquals("offset 3 on Date", expectedOffset3Date, interval.utc().offset(givenDate, 3).getTime());
		
		JsDate givenJsStart = givenJsDate;
		JsDate givenJsEnd = JsDate.create(expectedOffset3Date);
		assertEquals("range 3 on double", 3, interval.utc().range(givenJsStart.getTime(), givenJsEnd.getTime()).length());
		assertEquals("range 3 on JsDate", 3, interval.utc().range(givenJsStart, givenJsEnd).length());
		Date givenStart = givenDate;
		Date givenEnd = new Date((long) expectedOffset3Date);
		assertEquals("range 3 on Date", 3, interval.utc().range(givenStart, givenEnd).length());
		
		// FIXME : very strange behaviour on this one
//		assertEquals("range 3 with step on double", 2, interval.utc().range(givenJsStart.getTime(), givenJsEnd.getTime(), 2).length());
//		assertEquals("range 3 with step on JsDate", 2, interval.utc().range(givenJsStart, givenJsEnd, 2).length());
//		assertEquals("range 3 with step on Date", 2, interval.utc().range(givenStart, givenEnd, 2).length());
	}
 
开发者ID:gwtd3,项目名称:gwt-d3,代码行数:45,代码来源:TestTimeIntervals.java

示例10: goToDate

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
public void goToDate(final Date d) {
    if (d != null) {
        JsDate date = JsDate.create((double) d.getTime());
        goToDate(getElement().getId(), date);
    }
}
 
开发者ID:gwtbootstrap3,项目名称:gwtbootstrap3-extras,代码行数:7,代码来源:FullCalendar.java

示例11: apply

import com.google.gwt.core.client.JsDate; //导入方法依赖的package包/类
/**
 * Formats the specified date, returning the corresponding string.
 * 
 * @param date The date to format.
 * @return The formatted string.
 */
public final String apply(final Date date) {
    JsDate jsDate = JsDate.create(date.getTime());
    return apply(jsDate);
}
 
开发者ID:gwtd3,项目名称:gwt-d3,代码行数:11,代码来源:TimeFormat.java


注:本文中的com.google.gwt.core.client.JsDate.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。